I’m having an issue with onbeforeunload. I’m trying to have a popup appear only when the window closes not when any <a href is clicked. Any ideas? Is this even possible?
[CODE] <html> <head> <title>Untitled Document</title> </head> <body> <a href="http://www.google.com" > Google</a> <a href="http://www.yahoo.com" > Yahoo</a> <script> var linkclicked=false; links=document.getElementsByTagName("a") for (var i=0; i<links.length; i++) { links[i].onclick=function (){ linkclicked=true; } } window.onbeforeunload= function(){ if (linkclicked==false) { return "Leave Page?"; } }; </script> </body> </html> [/CODE]
Help @priyankavjkr spread the word by sharing this article on Twitter...