Search

3/16/2007

Setting the “name” attribute in Internet Explorer » Semicolon

Setting the “name” attribute in Internet Explorer » Semicolon
Death to bad DOM Implementations ¬ Easy Reader

function createElementWithName(type, name) {
var element;
// First try the IE way; if this fails then use the standard way
if (document.all) {
element =
document.createElement('< '+type+' name="'+name+'" />');
} else {
element = document.createElement(type);
element.setAttribute('name', name);
}
return element;
}

沒有留言: