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.
Clayton (October 27, 2007 at 10:18 pm)
I’m not sure if “works as advertised” quite covers this method, because Microsoft doesn’t advertise that this method is broken.
http://webbugtrack.blogspot.com/2007/10/bug-235-createelement-is-broken-in-ie.html
It does create the element requested, but since you have to butcher your arguments in order to overcome the .setAttribute(‘name’, … ); bug, it doesn’t quite have that spectacular “fresh off the shelf” feeling that it can take on the world.
I haven’t tried it, but I’m guessing that it likely won’t handle non-valid elements too. One could argue that it shouldn’t, but I can see a future need for a new element, that IE6 and IE7 might choke on now.