Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Location
    India
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Netscape error with onunload()

    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,907
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    I think that unload is a reserved word - try renaming your function to something else.

  • #3
    New to the CF scene
    Join Date
    Feb 2003
    Location
    India
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onunload() problem

    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

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,907
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •