Omicron Llama

Coding all day, every day.

document.getElementById() in MSIE

Ok, I think I screwed up somewhere – what I paste below breaks in all browsers, not just IE – if the getElementById is wrapped in a function and THEN called sometime after “OnLoad” is triggered, it works. Oh well…

Original Article –

This is strange. I have an issue which I have grossly simplified in order to explain the situation. Below are two snippets of code which work perfectly fine in all browsers but IE. The second code snippet gives the error message:

Message: ‘document.getElementById(…)’ is null or not an object
As you can see, the difference is that the javascript code is outside of the head tag and after the referenced div tag. Here’s the code that works in everything:

And here’s the code that breaks MSIE:

Does anyone have a scoobie how to get around this?

One thought on “document.getElementById() in MSIE

Leave a Reply

Your email address will not be published. Required fields are marked *