document.getElementById() in IE has some issues. The problem can be spotted when you have a page element with an id "description" and meta tag with a name "description" IE considers the meta tag to be the one that should be returned by getElementById(). Which is, of course, wrong. ID
is an ID
and name
is a totally different thing.
Anyway, heads up for that IE behaviour.
As an illustration, here in WordPress (the blogging tool that powers the page you're reading) there's a meta tag, called "generator", like this:
<meta name="generator" content="WordPress 1.5" />
So if you do:
alert(document.getElementById('generator'))
this will return null
in FireFox, the way it was meant to be (by w3c, that is) and in IE, you'll get [Object]
Try it...
Try it with the "content" property...
(The second example will give an error in FireFox as there is no "content" property of null
.
Comments? Feedback? Find me on Twitter, Mastodon, Bluesky, LinkedIn, Threads