...

View Full Version : Netscape error with onunload()



luanne
02-22-2003, 07:01 AM
Hi,

I am trying to capture the onunload() event and my script looks something like this:

<script>

function unload() {
alert("unloading");
}

</script>
....
....
<body onunload="unload()">
...
...

This is the error I get in Netscape 7 :
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowInternal.alert]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/WINDOWS/DESKTOP/Briefcase/clock.html :: unload :: line 94" data: no]

But, the same works fine in IE, Mozilla 0.9 and Netscape 4.05

Could someone please help? I really need to capture the onunload event. have also tried onUnload() but still doesn't work.
Thanks
Luanne

Philip M
02-22-2003, 05:27 PM
I think that unload is a reserved word - try renaming your function to something else.

luanne
03-01-2003, 06:36 AM
Hi,

I tried renaming the function, but still does not work.

I think the unload event is being captured and delegated to the function, but for some reason the function does not execute and throws an error like this :
Error: uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMWindowInternal.alert]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: file:///C:/WINDOWS/DESKTOP/Briefcase/clock.html :: unload :: line 94" data: no]

This happened when the function body consisted of an alert. No matter what I change to, I get the above error (with the nsIDOMWindowInternal.alert changed to confirm or whatever I have used).

There is no problem with Netscape 6. Only Netscape 7. Please help!

Thanks.
Luanne

Philip M
03-01-2003, 09:06 AM
I have no idea why you have this problem, but as a wild guess try putting something else into the function before the alert, e.g.

dummy=dummy+1;

If this does not work then I am stumped! Perhaps Beetle (the fount of all knowledge) can help!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum