jaymc Posted November 4, 2007 Share Posted November 4, 2007 I have a script executed when the OnUnload event occurs however, if the page is refresh, this counts as an UnLoad Due to the nature of my script, this is causing problems Is there any way around it? Quote Link to comment Share on other sites More sharing options...
emehrkay Posted November 5, 2007 Share Posted November 5, 2007 http://developer.mozilla.org/en/docs/DOM:window.onclose Quote Link to comment Share on other sites More sharing options...
jaymc Posted November 5, 2007 Author Share Posted November 5, 2007 That isnt working unless I have mistaken Here is test code <html> <head> <SCRIPT LANGUAGE="JavaScript"> window.onclose = alert('Closing') </script> </head> <body> adad </body> </html> When I refresh it gives the alert, when I close it doesnt Any ideas? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 5, 2007 Share Posted November 5, 2007 well got this code which works in IE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY onunload="logoutto()"> <script> function logoutto() { if ((window.event.clientY < -3000) && (window.event.clientX < -3000)) { // alert('Window closed'); } } </script> </BODY> </HTML> Quote Link to comment Share on other sites More sharing options...
jaymc Posted November 5, 2007 Author Share Posted November 5, 2007 Really? I tried that in IE7 and get no alert I am not closing a popup, its a fully loaded window, not a tab When you close are you getting the alert? huh Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 5, 2007 Share Posted November 5, 2007 Yes I am using IE6 though.... Quote Link to comment Share on other sites More sharing options...
jaymc Posted November 5, 2007 Author Share Posted November 5, 2007 ahh, perhaps doesnt work in IE7? I have done more testing and its the IF statement that IE7 doesnt like Is there something else you can use in that if to see if its a refresh or make the if code more comptable Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 5, 2007 Share Posted November 5, 2007 maybe u can add some alert statements and tell me if you get any alerts I do not have IE7 otherwise would of tested it <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY onunload="logoutto()"> <script> function logoutto() { alert(window.event.clientY); alert(window.event.clientX); if ((window.event.clientY < -3000) && (window.event.clientX < -3000)) { // alert('Window closed'); } } </script> </BODY> </HTML> Quote Link to comment Share on other sites More sharing options...
jaymc Posted November 5, 2007 Author Share Posted November 5, 2007 Ok its working, I have to change it from -3000 to the numbers those alerts where spitting out Cheers Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 5, 2007 Share Posted November 5, 2007 Thats cool Actually I swa this code in one(basically its not my code) of my projects maybe u can tweak it for all browsers since my client only uses IE6 (Its a closed banking software) so it worked like a charm Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.