Click to See Complete Forum and Search --> : onunload in <Body> Not working


clyde
04-07-2004, 07:51 AM
Please look at the simple html below:
The function defined in the onunload will not do the alert on my IE Exp. Browser, but will work on another PC's IE Exp. Browser.

How can this be.

any help would be appreciated.
Thanks
Clyde

<html>
<head>
<Script language="javascript">
function testun()
{
alert("Test UN Found");
}
</Script>
</head>
<body onunload="testun()">
<form>
Test Unload
</FORM>
</body>
</html>

fredmv
04-07-2004, 08:05 AM
Sounds like IE is up to no good again… :rolleyes:

Try these different variants:<script type="text/javascript">
//<![CDATA[
onunload = function() { alert('foo'); }
//]]>
</script><body onunload="alert('foo');">If those don't work, this indicates that either: Something is wrong with IE (come to think if it what isn't wrong with it — this is clearly redundant information). There is perhaps some weird setting on disallowing this to work correctly.In any case, re-installing IE might do the job — but a much better solution would be to install a real browser (http://www.mozilla.org/products/firefox/). ;)

clyde
04-07-2004, 09:29 AM
fredmv

I did find out what was stopping it from working on my PC.

I have the google tool bar and had the popup blocker active,
as soon as I disabled the pop up blocker the onunload function works.

With the pop up blocker running, I proved by putting a error into the onunload function, it never runs.

Any suggestions when dealing with pop up blockers.
Why do you think that the onunload basically does not work with the pop up blocker.

Any help would be appreciated.

Clyde

fredmv
04-07-2004, 09:30 AM
What likely is going on here is that the pop-up blocker assumes the JavaScript alert is a pop-up window hence why disabling it allows it to work.

clyde
04-07-2004, 09:36 AM
First of all , Thanks for your help.

What I am trying to do is to submit a job to my server, if the user X's or exits the browser. Is their any other method you know of to accomplish this other than the unLoad on the <BODY> tag

Clyde