View Full Version : window.onerror and Javascript failing to load

Sysmic Wave
07-06-2010, 10:43 AM
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.


07-06-2010, 11:41 AM
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.