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? Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/ 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 Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/#findComment-384705 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? Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/#findComment-384903 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> Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/#findComment-384910 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 Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/#findComment-384916 Share on other sites More sharing options...
rajivgonsalves Posted November 5, 2007 Share Posted November 5, 2007 Yes I am using IE6 though.... Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/#findComment-384917 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 Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/#findComment-384919 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> Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/#findComment-384931 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 Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/#findComment-385045 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 Link to comment https://forums.phpfreaks.com/topic/75966-solved-onunload/#findComment-385049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.