Friday, July 27, 2007

IE Javascript error: document.getElementById()

hit this javascript error last night testing a Firefox developed code base for bugs in IE

"object doesn't support this property or method"

I think it was because i had this pattern going:

f_name=document.getElementById('f_name');

Adding a var fixed the problem IE.

var f_name=document.getElementById('f_name');

(IE, remember that app with the blue e?, I only used it for Testing & Support these days, boy is it a chore to debug javascript with IE compared to Firefox!)

anyway, here's a solution which worked for me.

10 comments:

MovieLandmarks said...

Thanks! I developed movielandmarks.com using Firefox and was debugging using IE7, it ended up that the google map object needed to be declared in the global scope before assigning it in the load function.

Thanks for pointing me in the right direction!

Unknown said...

Thanks a lot! this was very helpful (ms script debugger, of course, was not!)

Anonymous said...

Thank you SO much!!!!!
Solved my problem directly.

Marc

Luis Rivera said...

Thanks!!!!!!
you saved my head
greetings from Mexico

Anonymous said...

Awesome man!
Just what i was looking for.
Solved my problem also.

Anonymous said...

Awesome man!
Just what i was looking for.
Solved my problem also.

Anonymous said...

thanks!!!! you would marry with you !!!!

Anonymous said...

IT WORKS! Great!...one question: but adding that "var" the code continues to work in Firefox without problems like before this mod? Thanks!

Zac Spitzer said...

Firefox should be fine, it's all about the order of scopes

Anonymous said...

Really works! Thanks!