11.9.2011 12:39, Andrew Poulos wrote:
> I suspect you are running your code before the element exists.
Sounds probable.
Such problem can easily be recognized by looking at the console error
log - and if someone doesn't know how to find it in his favorite
browser, it's time to learn!
There was once an FAQ hosted on jibbering.com/faq that listed how to
enable error reporting for various browsers. SInce we don't have an
FAQ now, we're all (including the OP) SOL. Sorry, buddy. Try and
figure out how to turn on error reporting in your browser. Get a
debugger, too.
If that takes too long, there's always the
possibility of wrapping the JavaScript code into...
try {
// all the code here
} catch(e) {
alert(e);
}
You can do that, but won't get anything meaningful out of IE versions;
just "[object Error]". e.name, e.message, but really, what you want is
all the information, including the line number. Turn on error
reporting in your browser.
Browsers are mostly silent about JavaScript errors because there are so
many of them.
So many errors, you mean? That's a reason users would want to hide
them, sure.
But in program development, there is hardly any reason not
to look at error messages!
Right. Turn on error reporting in your browser. Find the error
console. Get a debugger.