Click to See Complete Forum and Search --> : Pop up onClose


metaphiz
07-10-2003, 05:55 PM
I want to pop up a survey window from a single page when users close the window. It's a page in the middle of a shopping cart sequence so we don't want the survey to pop up unless they close the window. If it pops up when they leave the page for other pages of the site, it will defeat sales.

Does anyone have code for this?

Mr J
07-11-2003, 03:35 PM
This might do you


<html>
<head>
<title>Detecting Closing of Window in IE</title>
<script language="javascript">
function doUnload(){
if ((window.event.clientX < 0) && (window.event.clientY < 0)){
alert("The window is closed...");
}
}
</script>
</head>
<body onunload="doUnload()">
<h3>Detecting Closing of Window in IE</h3>
Try the 3 ways below and see the difference:<br>
1. Refresh the page.<br>
2. Type any URL in the address bar.<br>
3. Close this window by clicking X button of this window.
</body>
</html>