W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2002

getElementById and case sensitivity

From: Thor Larholm <Thor@jubii.dk>
Date: Mon, 1 Jul 2002 15:44:15 +0200
Message-ID: <52D05AEFB0D95C4BAD179A054A54CDEB03470A26@mailsrv1.jubii.dk>
To: "'www-dom@w3.org'" <www-dom@w3.org>

There is an inconsistant behavior in how the 2 major DOM implementations
(IE/Mozilla) treat cases in ID attributes when referencing elements with
getElementById.

Consider the following example:


<div id="crappeR">first</div>
<div id="crapper">second</div>
<script type="text/javascript">
alert( document.getElementById("crapper").innerHTML );
</script>


IE will disregard cases and display "first", while Mozilla will honor cases
and display "second".

The DOM Level 1 recommendation is not clear about which to use.

DOM Level 1:
getElementById(elementId) 
This method returns a Element.
The elementId parameter is of type DOMString. 

DOM Level 1 2nd Ed.:
getElementById(elementId) 
This method returns a Element object. 
The elementId parameter is of type String.


To settle any doubts I ask: Which behavior is correct?


Regards
Thor Larholm
Jubii A/S - Internet Programmer
Received on Monday, 1 July 2002 09:47:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:56 GMT