469,327 Members | 1,265 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

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 2614
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
reply views Thread by suresh191 | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.