miscoded

the web is a hack

Dell goes for the quirks

, , , ,

This page should have a Flash in it. Now Opera, where is it?

Well, here's a pretty little function from Dell, meant to return an element with a specific name:

function ParseDivObjects( targetName )
{
var objs = document.getElementsByName( targetName );

//-- Workaround for "inconsistent" W3C ruleset in IE as DIV's aren't mapped with name properties
if( objs.length == 0 )
{
var targets = document.getElementsByTagName( "DIV" );
var tmpObj;

objs = new Array();

for( var targetidx = 0; targetidx < targets.length; targetidx++ )
{
tmpObj = targets[targetidx];
if( tmpObj.name == targetName )
{
objs.push( tmpObj );
}
}
}
return objs;
}


Let's start: document.getElementsByName is not supposed to be used for elements that are not supposed to have a "name" attribute. So, for example you can use getElementsByName with INPUT elements but not with DIV. Except that Mozilla apparently disagrees with that interpretation of the specification and thinks IE's behaviour is "a quirk". Really?

Anyway, Dell has a workaround for IE: they go through all DIVs in the page and check tmpObj.name, which means Opera is out of luck again. Since DIVs are not meant to have a "name" attribute we don't create any .name property for it. Using getAttribute here would make it work.

So Dell crams two different quirks into one function, and Opera fails because it supports neither. Time to violate the DOM spec a little more.. sad

GMail's while(1) demystifiedTwo small steps for Gates towards a better web

Comments

Jere Monday, May 22, 2006 2:24:32 PM

Ehm... why don't they just use an ID scared

Kelson VibberKelson Monday, May 22, 2006 5:11:31 PM

@Jere: That was my first thought as well. This seems like a clear case of using a screwdriver as a hammer and trying to work around the fact that it doesn't pound nails very well.

Hallvord R. M. Steenhallvors Monday, May 22, 2006 6:01:14 PM

I think they use "name" because the script is meant to support embedding several Flash thingies in one page.

Andrew Gregory Tuesday, May 23, 2006 1:46:08 AM

I can see Mozilla's point of view...

Hallvord R. M. Steenhallvors Wednesday, May 24, 2006 11:54:30 PM

I guess it will later boil down to another question of DTD parsing and how to determine the "name-ness" of an attribute, just like with ID - but hey, I think the spec is unclear and what Mozilla does is the behaviour a web developer who didn't read the fine print would expect so I'd like us to follow them..

qicai02 Wednesday, June 7, 2006 9:30:28 AM

cheers

Write a comment

New comments have been disabled for this post.