Results 1 to 2 of 2

Thread: window.onerror and Javascript failing to load

  1. #1
    Join Date
    Jul 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default window.onerror and Javascript failing to load

    Hi folks, hope you can help.

    I've written a window.onerror function that retrieves the line number etc of the error and it works great.

    My issue lies with when my external JavaScript.js won't load i.e i've typed vrar instead of var or missed a curly brace.

    I still get the yellow exclamation telling me 'Object Expected' but as the JavaScript hasn't loaded properly my window.onerror doesnt function/run.

    Will I have to create seperate script tags and window.onerror functions in each of my individual pages rather than reference the onerror function from my main external JavaScript file?

    Any other ideas are welcome.

    Cheers

  2. #2
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Default

    I don't think I fully understand your problem... AFAIK you can't catch parse errors with window.onerror, which means that your current situation as I understand it can't be improved.

    However, if you could catch parse errors, I would understand you to mean that window.onerror is at the top of your code and parse errors further along prevent it from catching the same parse errors. If this is the case, then it might make sense that a separate script file would allow onerror to run because of how a browser loads JavaScript - although that doesn't sound like a very portable technique.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

Bookmarks

Posting Permissions

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