Tuesday, September 23, 2008

Handling the Javascript Errors

1.Method using onerror event

onerror=handleErrors; //Invoke the method here

//Method definition

function handleErrors(msg,url,lineno)
{
//Here we will get the error message along with page url with lineno so tracking the error will be easier
//Handle the error here
return true or false
}


2.Try and Catch block

try
{
//Run some code here
}
catch(err)
{
//Handle errors using error object
}

No comments: