Helpful Information
 
 
Category: JavaScript programming
Error Script

Look At This:

function reportError(msg,url,line) {
var str = "<center>Err: " + msg + "<br>on line: "
+ line + "<br>URL: " + url + "<br>Web: "
+ navigator.appName + "<br>" + navigator.appName
+ "<BR>" + navigator.appVersion + "</center>";
pop = window.open("","","width=400,height=400");
pop.document.write(str)
return true;
}
window.onerror = reportError;

tim

cool that could be used in conjuction with a form to help debug your website.
very neat.

scroots

Arn't i the best ;-) (CLUE)
:p :o :o :p

Cool.....but how does the script pass the arguments onError?

The onerror event is in so far special that it automatically passes these three arguments to any handler function defined for that event.

That is ABSOLUTLY correct!

I love this script. If you combine it with a 'e-mail' script. (IE Sambar Server ect.) you can send the error streight to your inbox!

i've actually done that on my site. for me, it's useful, because i have no traffic whatsoever, and it's not a lot of emails to get.

but if you have lots of traffic, and there's a little tiny javascript problem somewhere, then you'll suddenly have a whole bunch of emails in your mailbox

arrrrrrrr,

That makes my 12YO soul happy ;)

Umm, wrong forum. This belongs in the Post a Javascript category.

BTW, if you want to make it really good, look into the individual error properties.

For example, thanks to resident moderator Alex Vincent, relatively recent Gecko builds (includes NS7, maybe latest NS6) include a "stack" property of an Error() object, which is basically a stack trace. Very useful in debugging.

Originally posted by joh6nn
i've actually done that on my site. for me, it's useful, because i have no traffic whatsoever, and it's not a lot of emails to get.

but if you have lots of traffic, and there's a little tiny javascript problem somewhere, then you'll suddenly have a whole bunch of emails in your mailbox

I am mainly an ASP (vbscript) programmer so javascript isn't my strong suit. How would one have the page send an email on error?

Thanks in advance,
Michael

you set up a server side script that sends email, and a page with a form. you use the error function to copy the important information to the form, and then javascript has a submit() method for forms. so you can use javascript to send the form, which then sends you all of the information from your javascript errors. i also have it set up to fire when i have a 404 error, or a server error

Originally posted by jkd
For example, thanks to resident moderator Alex Vincent, relatively recent Gecko builds (includes NS7, maybe latest NS6) include a "stack" property of an Error() object, which is basically a stack trace. Very useful in debugging.

Sorry, not in NS6.2. It will be in NS7.










privacy (GDPR)