Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12

Thread: Error Script

  1. #1
    Banned
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb 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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    1,137
    Thanks
    0
    Thanked 0 Times in 0 Posts
    cool that could be used in conjuction with a form to help debug your website.
    very neat.

    scroots
    Spammers next time you spam me consider the implications:
    (1) that you will be persuaded by me(in a legitimate mannor)
    (2)It is worthless to you, when i have finished

  • #3
    Banned
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Arn't i the best ;-) (CLUE)

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mumbai, India
    Posts
    218
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool.....but how does the script pass the arguments onError?

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The onerror event is in so far special that it automatically passes these three arguments to any handler function defined for that event.

  • #6
    Banned
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #7
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    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
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #8
    Banned
    Join Date
    Jun 2002
    Location
    Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    arrrrrrrr,

    That makes my 12YO soul happy

  • #9
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    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.

  • #10
    New Coder
    Join Date
    Jul 2002
    Location
    Houston, TX
    Posts
    84
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #11
    Senior Coder joh6nn's Avatar
    Join Date
    Jun 2002
    Location
    72° W. 48' 57" , 41° N. 32' 04"
    Posts
    1,887
    Thanks
    0
    Thanked 1 Time in 1 Post
    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
    bluemood | devedge | devmo | MS Dev Library | WebMonkey | the Guide

    i am a loser geek, crazy with an evil streak,
    yes i do believe there is a violent thing inside of me.

  • #12
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,461
    Thanks
    1
    Thanked 23 Times in 21 Posts
    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.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •