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?
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?
Comment