Jump to content

onerror


Guest Rajeev Pandey

Recommended Posts

Guest Rajeev Pandey

The section on 'onerror' mentions:The value returned by onerror determines whether the browser displays a standard error message. If you return false, the browser displays the standard error message in the JavaScript console. If you return true, the browser does not display the standard error message.The program given along with this statement is:<html><head><script type="text/javascript">onerror=handleErrvar txt=""function handleErr(msg,url,l){txt="There was an error on this page.\n\n"txt+="Error: " + msg + "\n"txt+="URL: " + url + "\n"txt+="Line: " + l + "\n\n"txt+="Click OK to continue.\n\n"alert(txt)return true}function message(){adddlert("Welcome guest!")}</script></head><body><input type="button" value="View message" onclick="message()" /></body></html>However, I found that it does not make any difference whether the value returned by handleErr() is true or false.

Link to comment
Share on other sites

What browser are you using?Test results with IE6, FF were..With the "return false":IE6 Displays the error icon lower left corner, homemade alert and regular error alertFF Turns on the alert icon(upper right hand corner)(javascript console records error) Homemade alert displaysWith the "return true":IE6 Displays homemade alert, nothing elseFF Displays the homemade alert, nothing elseSo the return true keeps the user from worrying about the error.Of course your results will depend on your browser's user settings.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...