Jump to content


This topic is now archived and is closed to further replies.


getElementById troubles(solved)

Recommended Posts

Ok, i have solved my previous problem but have another so i might as well just modify this topic.

why does this:
work, and not this:

As i understand it, you shouldn't use all anymore, but use getElementById, and certainly Firefox gives a warning although it still functions.

Any help would be much appreciated.

Thanks, Ben

Share this post

Link to post
Share on other sites
Try to stick to methods and props defined in the DOM level 2 W3C recommendation, and implement fixes for IE.

[code]document.getElementById('due').nodeValue = date;[/code]

Should work in at least IE6 and FF, not sure about all versions of IE5.

You might have to use a little [url=http://"http://javascriptkit.com/javatutors/objdetect2.shtml"]object detection[/url].

Some older versions of IE use the "document.all" model, which sucks, but is better than nothing:

[code]if (!document.getElementById) {
      if(!document.all)  {
        //DOM not supported :'(
            else {
            //Document.all model
        else {
        //W3C DOM
        document.getElementById('due').nodeValue = date;

FF did partly adopt Microsoft's document.all model for older sites still using it.

Share this post

Link to post
Share on other sites
Thanks for your help although it seems i must have made a typo when trying what i did above, as that is working fine now in both FF and IE6.

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.