Dell goes for the quirks
Monday, May 22, 2006 1:57:49 PM
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..








Jere # Monday, May 22, 2006 2:24:32 PM
Kelson VibberKelson # Monday, May 22, 2006 5:11:31 PM
Hallvord R. M. Steenhallvors # Monday, May 22, 2006 6:01:14 PM
Andrew Gregory # Tuesday, May 23, 2006 1:46:08 AM
Hallvord R. M. Steenhallvors # Wednesday, May 24, 2006 11:54:30 PM
qicai02 # Wednesday, June 7, 2006 9:30:28 AM