Custom Js Error Messages





11
Date Submitted Thu. Aug. 10th, 2006 2:25 AM
Revision 1 of 1
Syntax Master sundaramkumar
Tags JavaScript
Comments 1 comments
when an javascript error is occured , instead of showing the default error message by the system, we can show the our own cusom error message like this.



function handleErrors(msg, url, line)
{
var errorString = "JavaScript Error Occured\n";
errorString += "Message: "+msg+"\n";
errorString += "Url: "+url+"\n";
errorString += "Line: "+line;
alert(errorString);
return true;
}

window.onerror = handleErrors;

 
If you want to suppress the error message just comment out the alert(errorString); line. the javascript errors will be suppressed and the user cannot see any js errors

Comments

Comments To suppress errors . . .
Fri. Sep. 22nd, 2006 7:18 AM    Scripter sehrgut

Voting