...

View Full Version : IE bug when setting events on elements..



fci
10-12-2004, 06:08 AM
I tested this on IE6 on two different computers..


<body></body>
<script>
text = document.createElement('textarea');
text.setAttribute('onFocus','alert(1)');
//text.setAttribute('onfocus','alert(1)');
//text.onfocus = "alert(1)";
//text.onFocus = "alert(1)";
document.body.appendChild(text)
</script>

It works in Fx but not in IE
I Googled to see if it was a known bug but did not find any information-- maybe I wasn't using the proper search terms. I also tried the above with onblur which still yielded no results, the attribute is set but the event just does not occur.
I will use innerHTML instead unless you have another suggestion..

Willy Duitt
10-12-2004, 10:07 AM
text.onfocus = function(){alert(1)};

fci
10-12-2004, 11:49 AM
wahoo! thanks willy.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum