DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Error handling (http://www.daniweb.com/forums/thread115036.html)

dolphin.rise Mar 21st, 2008 8:05 am
Error handling
 
I am new to javascript and have made a simple form accepting details of login on a web page. I fail to understand how the following code handles the error when written between script tags:
function errorhandler(errormessage,url,line)
{
alert("Error :"+errormessage);
alert("url :" +url);
alert("line :"+line);
return true;
}
onerror=errorhandler;
Could someone help me!!!

ExplainThat Mar 21st, 2008 9:46 am
Re: Error handling
 
There are two ways to handle error
  • onerror - which just allows you to carry on gracefully when there is an error but takes little corrective action
  • The try..catch code block that allows you to trap the error and deal with its consequences

I discuss this, and many other JS issues, in my quickreference guide

JavaScript Quick Reference

Hope this helps.


All times are GMT -4. The time now is 3:59 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC