...

View Full Version : setAttribute() and IE6



ManyStylez
12-10-2010, 05:49 PM
Having some issues with setAttribute() and IE6, works in other browsers just being illusive in IE6.

Any help here would be great. :)

Currently using IETester v0.4.6.

Stylez.



<div id="Element">Element</div>

<script>
document.getElementById("Element").setAttribute('onclick', 'alert("!")');
</script>

Logic Ali
12-10-2010, 06:30 PM
Never use setAttribute when direct assignment will work:

document.getElementById("Element").onclick = function(){ alert("!"); };

ManyStylez
12-10-2010, 08:27 PM
Thanks for that tip :)

Dormilich
12-11-2010, 11:24 AM
PS. Element is the name of a DOM interface object. and because IE writes all IDs and names in the global scope, you can get name collision.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum