Friday, March 20, 2009

Friday night javascript notes

Uhg! A few things that are worth writing down - the kind of things you know but then forget you know when you are programming.

First - The DOM is case sensitive in Firefox, not in I.E. though... So imageId3 is different than ImageId3 as far as Mozilla is concerned.

O.K. that first one is like Duh! but this second point is not so much, as it turns out that if you have a variable that hasn't been assigned yet I.E. doesn't really care so much, you can try and talk to it and nothing happens - Firefox on the other hand blows up, at the least the function does. the minute you try and access that null variable Mozilla throws an error and the rest of the function won't execute. The trick is to see if there is a value assigned to it. I searched the web for a while and finally over at someone gave me this code.

if(typeof imageContainer == 'undefined')

There is an explanation at the original post.

OK - That's it for now, hope that helps you out on your JS travels.

No comments:

Post a Comment