471,896 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,896 software developers and data experts.

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="ScriptError.jsp" id="controllerFrame"
name="controllerFrame" height=150 width="450"
APPLICATION="yes"></IFRAME>
<BR>
<DIV id=oErrorLog style="border:1px groove orange
;width:450px;height:200px; "></DIv>
<SCRIPT>
var frm=document.frames;
window.onerror=fnErrorTrap;
oErrorLog.innerHTML=frm(1).name;
function fnErrorTrap(sMsg,sUrl,sLine){
alert("err");
oErrorLog.innerHTML="<b>An error was thrown and caught. </b><p>";
oErrorLog.innerHTML+="Error: " + sMsg + "<br>";
oErrorLog.innerHTML+="Line: " + sLine + "<br>";
oErrorLog.innerHTML+="URL: " + sUrl + "<br>";
return true;
}
</SCRIPT>

ScriptError.jsp is as:

<BODY>
<INPUT TYPE="text" ID=oErrorCode VALUE="someObject.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?

Jul 23 '05 #1
1 2651
Ivo
"suganya" wrote
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. <snip> window.onerror=fnErrorTrap;


You could add a line like this:

window.frames[yourframename].onerror=fnErrorTrap;

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

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Krishna Srinivasan | last post: by
4 posts views Thread by teddysnips | last post: by
1 post views Thread by Ron St-Pierre | last post: by
6 posts views Thread by Ron St-Pierre | last post: by
reply views Thread by Evert | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.