I get an error when I try to dynamically add an attribute to some elements, since I been getting the error “Object doesn’t support this property or method” in IE I reduced the attribute value to just alert.
function initialize_containers()
{
var containers = document.getElementsByClassName("boxcontainer");
var i = 0;
for (i = 0; i < containers.length; i++)
{
containers[i].setAttribute("onmouseover", "alert('hello world');");
}
}
window.onload = function() { initialize_containers(); };
note that in firefox all the elements with the class boxcontainer gets “hello world” alert. I removed this specific code (shown above) out of the page and the error in IE goes away, so I’m 100% sure nothing else is causing it. Any suggestions?
It uses span tag, but other than that assigning id’s to all the spam is not an option, is there a IE alternative workaround for getElementsByClassName?