Window.onerror does not work in Internet Explorer

  1. chris

    I have a "parent" window that opens a "child" window. The child window calls a function in the parent window that sets the "onerror" handler for the child. Netscape has no trouble with this, but IE does not set the "onerror" handler. The function call works, but window.onerror is not set.
    This works if the "onerror" handler is in the child window. Any ideas? Thanks.

    Chris

    <!-- Save the first 20 lines of this code as parent.htm -->
    <html>
    <head>
    </head>
    <body>
    <script>
    window.open("child.htm", "child");
    function setError(child) {
    child.onerror=onErrorHandle;
    child.sample="Yes";
    }
    function onErrorHandle(msg){
    document.write (msg);
    return true;
    }
    </script>
    </body>
    </html>
    <!-- End of parent.htm -->

    <!-- Save the rest of this code as child.htm -->
    <html>
    <head>
    </head>
    <body>
    <SCRIPT LANGUAGE="JavaScript">
    sample="No";
    alert ("SAMPLE "+sample+'\n ONERROR '+onerror); // sample is "No", onerror is null
    opener.setError(self);
    alert ("SAMPLE "+sample+'\n ONERROR '+onerror); // sample is now "Yes", onerror is still null
    </SCRIPT>
    </body>
    </html>
    <!-- End of child.htm -->

    Posted: 2002-05-13 14:49:56 #

  2. Pallavi

    try changing the variable name 'onerror' to something else. i tried changing it to 'onerr' and it works. am not sure why it works on changing the variable name...but will let u know if i manage to find out. do let me know if u know the reason.

    Posted: 2004-06-15 08:33:33.764106 #

:
: