Click to See Complete Forum and Search --> : Problem with popup windows on exit


lastat
01-15-2003, 12:13 PM
Hi, I am Robert. I have been desperatelly strugling with the following Java Script problem:

I was told to create a pupup questionnaire that is to open in a separate popup window only when a user exits or leaves the current web page. That means if user either closes the browser window or presses the back button or types a different URL.

I have partially done so but when I browse inside the web page ( I mean whenever I click on links on this web page) the popup comes on each time ... and I DO NOT WANT IT POPPING UP each time I click on a link.

AND 1 more thing: I need this to work perfect under IE4,5 & 6 also for NS 5 & 6

Is there a command like onExit which should ensure that if the current URL is changed or left it triggers the popup???

Thanks

Robert :confused:

swon
01-15-2003, 12:21 PM
Try this one:

<body onUnload="yourFunction()">

lastat
01-15-2003, 12:26 PM
I already have the script which is this one:

<script language="JavaScript">

window.onload = function() {for (j=0;j<document.links.length;j++) {document.links[j].onclick = function () {window.onunload = function() {}}}}

</script>

This works with IE6x all right but the lill problem comes with
when viewed under lower IE versions then IE6.

Is there a script that justifies the browser versions so that it works under them good??

Robert

swon
01-15-2003, 12:34 PM
For Browser Version use something like:

browser_name = navigator.appName;
browser_version = parseFloat(navigator.appVersion);
alert(browser_name + browser_version);