joecool2005 Posted March 1, 2006 Share Posted March 1, 2006 Hi,When a window is pop up, is it possible to dertermine if the window is closed by a click or by a pop up stopper.thxJoe Link to comment Share on other sites More sharing options...
aspnetguy Posted March 1, 2006 Share Posted March 1, 2006 This only catches if the user closed the popup with X in IE...I couldn't get it to work in FireFox. But everything else works in all browsers.parentPage.html <html><head> <title>test</title><script type="text/javascript"> function popUp(url) { var myWin = window.open(url,'newWindow','width=300,height=300'); if(myWin == null) alert('New window blocked by Popup Blocker'); }</script></head><body onload="popUp('popup.html')"> <a href="javascript:popUp('popup.html')">Open Window</a></body></html> popup.html <html><head> <title>test</title><script type="text/javascript"> function doClose(e) { if(!e)var e = window.event; if(e.clientY < 0) alert('User clicked X to close window'); } function closeWindow() { alert('User clicked link to close window'); window.close(); }</script></head><body onbeforeunload="doClose()"> <a href="javascript:closeWindow('popup.html')">Close Window</a></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now