setAttribute not working for onclick in IE

August 8, 2008

You can’t use javascript setAttribute() to set an onclick event on a link in Internet Explorer, I’ve discovered. You have to use <element>.onclick = <something> instead.

SeeĀ  here http://justinfrench.com/index.php?id=25 and here http://www.quirksmode.org/js/events_tradmod.html

3 Responses to “setAttribute not working for onclick in IE”

  1. idleboy Says:

    thanks mateeeeeee

  2. trevor Says:

    events are only a few of the attributes IE can’t set properly.

    See this bug report for details on all of them.

    http://webbugtrack.blogspot.com/2007/08/bug-242-setattribute-doesnt-always-work.html


Leave a Reply