suppress script errors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • suganya

    suppress script errors

    window.onerror is used to catch and supress the script error. but it
    will catch the error only when the script is within the same source
    file.

    for example, consider a html file MainFrame.htm as,

    <IFRAME src="ScriptErro r.jsp" id="controllerF rame"
    name="controlle rFrame" height=150 width="450"
    APPLICATION="ye s"></IFRAME>
    <BR>
    <DIV id=oErrorLog style="border:1 px groove orange
    ;width:450px;he ight:200px; "></DIv>
    <SCRIPT>
    var frm=document.fr ames;
    window.onerror= fnErrorTrap;
    oErrorLog.inner HTML=frm(1).nam e;
    function fnErrorTrap(sMs g,sUrl,sLine){
    alert("err");
    oErrorLog.inner HTML="<b>An error was thrown and caught. </b><p>";
    oErrorLog.inner HTML+="Error: " + sMsg + "<br>";
    oErrorLog.inner HTML+="Line: " + sLine + "<br>";
    oErrorLog.inner HTML+="URL: " + sUrl + "<br>";
    return true;
    }
    </SCRIPT>

    ScriptError.jsp is as:

    <BODY>
    <INPUT TYPE="text" ID=oErrorCode VALUE="someObje ct.someProperty =true;">
    <script>
    document.write( eval(oErrorCode .value));
    </script>
    </BODY>

    in the script of MainFrame.htm, frm(1) is null object and the error is
    catched and suppressed, but the file scriptError.jsp also has the
    script errror. what i need is to catch the error in scriptError.jsp
    also from the MainFrame.htm, is it possible to catch the error?

  • Ivo

    #2
    Re: suppress script errors

    "suganya" wrote[color=blue]
    > window.onerror is used to catch and supress the script error. but it
    > will catch the error only when the script is within the same source
    > file.[/color]
    <snip>[color=blue]
    > window.onerror= fnErrorTrap;[/color]

    You could add a line like this:

    window.frames[yourframename].onerror=fnErro rTrap;

    before or after the content of the frame has been written, you 'll need to
    experiment with that..
    Or add a error trapping function in your document.write statement.
    hth
    --
    Ivo



    Comment

    Working...