« CGI::Ajax, Using Perl to do AJAX | Main | AJAX Timeouts with Prototype »

Internet Explorer and standards : Case Sensitive document.getElementById

I know that IE have their own standards, but is it a feature or a bug ? Today I was working on a web-application using advanced forms with Javascript and AJAX, and I noticed something strange. The developer who created the forms is using always IE, and I followed the developpement until everything is done as expected. But when I moved to test it myself on my new Firefox 2.0a1 I got an error message : Error: document.getElementById("dV1_DAY") has no properties. After googling I found some posts talking about it and this demo page answered my question :

document.getElementById isn't case sensitive in Internet Explorer, which is supposed to be case-sensitive according to the W3 specification. Mike Bulman have written a small script to correct this, you can include it in your page so document.getElementById will be always case sensitive. Or simply use Firefox :-)

Bookmark this article at these sites
Comments
1

Hmmm... Interesting, but the idea you'd need a script to correct the issue strikes me as kinda stupid. Just refer to your objects by their correct name.

I'm no IE fanboy, but jeez... Seems to me like the standards zealots have a little too much free time.

2

Let me see if I got this right:

You want to go out of your way, and write additional code just to FORCE something to be case-sensitive when it's not?

Rather than do that, and use FireFox, why not just use IE and consider it a non-issue?

Case sensitivity is one of the main reasons I abhor fiddle-farting around with javascript and other similarly handicapped languages that insist on using this main-frame era throwback requirement (that used to have a valid reason) that's now been carried over as nothing more than a formality or custom - and a stupid and baseless custom at that.

WOuld you not have understood me correctly if I said "Custom" instead of "custom"? WOuld you be confused by my question because I spelled it "WOuld?"

If someone reading my code saw "if cVar1 != strTrim(cVar2)..." and then saw the function declaration as "int function StrTrim()...", would they really be confused by that? Who would? Only a 30 year old compiler that's got a whopping 32k total memory to work with would find that confusing - but it has a good reason (namely, 32k total memory).

I spent 16 years writing C code on both mainframes and desktops. VB (and by implication VBscript) is a BIG improvement.

There is simply no reason and no excuse for a thing like case-sensitivity in this modern world - and going out of our way to prop up this outdated ritual is just dumb.


3

The above code is wrong... follow the link to
the link to get a fix.
BTW the problem is not case-sensitivity vs. case-insensitivity it's rather that:
document.getElementById(id).id == id
does not necessarily hold for IE, whereas
window[id].id == id
does! (assuming id exists in the page).
That's inconsistency.

4

[off topic -- apologies in advance]
Ian, if you are the Ian Castleden who contributed to Jython, and wrote an MS Excel interface package in Python, please contact me: "sjmachin" "\x40" "lexicon" "\x2e" "net"
TIA,
John Machin

5

This code is great!
Thank you for that, I had to create remote UNIX file manager with multiple file selection and many times users had two files, same name - different cases (GetAllHFIDs.sql and GetAllHFids.sql) in their directories.
it worked for me the first time, didn't need to change anything... don't know what some people here moaning about...
I've just put it at the first just after the tag.

Thanks again!

6

Thx for this code.
I think there is just a mistake on line 10.
it should be:
if (!o) break;
instead of:
if (!o) return o;

PS: I still do not understand why Microsoft is still doing a thing where all the other are doing something else.

Post a comment





(Email will remain hidden)





Please enter the security code you see here




Related entries
Email to a friend
Email this article to:


Your email address:


Message (optional):