Jump to content

Pop up window


joecool2005

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...