wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes getElementByID not working in Firefox but works in IE? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "getElementByID not working in Firefox but works in IE?" Watch "getElementByID not working in Firefox but works in IE?" New topic
Author

getElementByID not working in Firefox but works in IE?

John Zwick
Ranch Hand

Joined: Mar 02, 2009
Posts: 34
I am receiving the following error in the Error Console of Firefox however it works perfectly fine in IE 6:
"dropDownElement is null"



Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I see a name, not an id.

id != name

Eric
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
Eric Pascarello wrote:I see a name, not an id.

id != name

Eric

As Eric said and just to point this out, line referred is Line 12. 'id' attribute should be added.


Experience and talent are independent of age
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
To add, that's not the only funny thing that happens in IE. IE does not follow the strict or transitional parsing of HTML. id can be replaced by name for IE. I am not sure if this is true for IE8 but till 7.x that's the case.

For testing the UI, safari or opera or firefox are good options, also now we have chrome.
John Zwick
Ranch Hand

Joined: Mar 02, 2009
Posts: 34
Thanks for the fast replies everyone
I'm going to stop testing using IE once and for all!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's fine as long as none of your users use it.
Himanshu Kansal
Ranch Hand

Joined: Jul 05, 2009
Posts: 257
John Zwick wrote:Thanks for the fast replies everyone
I'm going to stop testing using IE once and for all!

Noooooooooo!!! don't stop testing on it. but do use at least 1 of others.

I test on IE and Opera. We need to test only make sure the UI is consistent and to facilitate the end-user's experience.
Trilochan Bharadwaj
Ranch Hand

Joined: Feb 02, 2009
Posts: 100
Himanshu, thats true, which is why I'd wanna repeat what Bear always pushes ... use external libs for some of the DOM and Event stuff, for example Dojo and other frameworks would always work in cross browser way, so you don't have to worry about it yourself and you can focus on the "job" at hand so as to speak.

BTW, on IE, I doubt if there is any organization that has completely abandoned IE testing, most of teams I have worked with test predominantly on IE, and all bugs related to js on Firefox et. al are marked minor (usually the case), but I am pretty sure it varies with organization, but generally one <b>should</b> test on IE. IE8 looks better than 7, but I haven't played with it completely, but there are differences on being non-standard(still ... things like Event bubbling), which stinks, I don't understand why Msft is so hell bent on being non-con formant.

I personally was in love with firebug and Firefox, but then i found Chrome ... it is just so fast (I don't have any benchmarks to back that up I am afraid, just personal experience with it), plus it has firebug kinda thing built into it, much better.

Trilochan.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

I develop on Firefox/Safari and test on IE. That way, the code follows the standards and only needs to deviate when it's absolutely necessary in order to work on the toy browser.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getElementByID not working in Firefox but works in IE?
 
Similar Threads
what to do, if I get error `breaking on JScript rumtime error - object expected
Setting radio button value dynamically and rendering partially after ajax request
Hiding/Showing div elements using Javascript
Javascript "options value" works in Firefox but not in IE
my overlay box works in Firefox, but fails in IE8