IE DOM/DHTML Bugs

During the re-write of the Schedule Maker, I’ve encountered a number of ‘issues’ that exist when developing cross-browser web applications, mainly in Internet Explorer. I’ll point out a couple important ones here:

  • document.createElement()

    – This command works as advertised in both IE and Firefox, with one notable exception – if you create an element that is not part of the HTML spec, you cannot access the normal DOM functions. Specifically, the code looked something like this:

    var d = document.createElement("data"); d.appendChild( elem );

    To which, Internet Explorer complains stating that the method is not supported.

  • xmlDoc.getElementById()

    – When importing XML from an outside source, using XMLHTTPRequest, IDs may not be properly assigned to the elements. According to the XML spec, in order to specify an ID you have to include a DOCTYPE that specifies it as such. However, it appears as if IE even ignores this. Instead, I just rolled my own getById() function to handle the request. Obviously, this is less then ideal, but the number of ID requests that I make was minimal, making this ‘not that bad’.
    CDATA:

    <!DOCTYPE data [<!ATTLIST course id ID #IMPLIED>]>

    getById() Function:

    function getById( obj, name ) {   return getByTypeId( obj, "*", name ); }  function getByTypeId( obj, type, name ) {   var c = obj.getElementsByTagName( type );   for ( var i = 0; i < c.length; i++ ) {     if ( c[i].getAttribute("id") != null && c[i].getAttribute("id") == name )       return c[i].cloneNode( true );   }   return null; }

I'm not sure if these error stem from actual bugs in the browser or if they're programming errors, but I fought them for hours and have grown to hate their existance.

Posted: January 25th, 2005


Subscribe for email updates

1 Comment (Show Comments)



Comments are closed.
Comments are automatically turned off two weeks after the original post. If you have a question concerning the content of this post, please feel free to contact me.


Secrets of the JavaScript Ninja

Secrets of the JS Ninja

Secret techniques of top JavaScript programmers. Published by Manning.

John Resig Twitter Updates

@jeresig / Mastodon

Infrequent, short, updates and links.