D
dhtml
getElementById doesn't work in IE. IE returns elements that have the
name matching.
So how about replacing getElementById conditionally, after a feature
test.
/**
* XXX: IE Fix for getElementById returning elements by name.
*/
if((function(){
try {
var d = document, x = d.body,
c = d.createElement("<a name=APEgEBITest
style='display:none'>"),
r;
x.insertBefore(x.firstChild);
r = d.getElementById('APEgEBITest');
x.removeChild(c);
return r;
} catch(ex) {}
})())
document.getElementById = function (id) {
var d = document, el = d.getElementById(id), els,i, len;
if(el.id == id) return el;
els = d.getElementsByName(id);
for(i = 0, len = els.length; i < len; i++)
if(els.id === id) return els;
return null;
};
Garrett
name matching.
So how about replacing getElementById conditionally, after a feature
test.
/**
* XXX: IE Fix for getElementById returning elements by name.
*/
if((function(){
try {
var d = document, x = d.body,
c = d.createElement("<a name=APEgEBITest
style='display:none'>"),
r;
x.insertBefore(x.firstChild);
r = d.getElementById('APEgEBITest');
x.removeChild(c);
return r;
} catch(ex) {}
})())
document.getElementById = function (id) {
var d = document, el = d.getElementById(id), els,i, len;
if(el.id == id) return el;
els = d.getElementsByName(id);
for(i = 0, len = els.length; i < len; i++)
if(els.id === id) return els;
return null;
};
Garrett