[thelist] setAttribute(someevent) in IE?

RUST Randal RRust at COVANSYS.com
Tue Jun 1 13:16:30 CDT 2004


sbeam said:

> ===
> <a id="thelink" href="#">Click Me</a>
> <script type="text/javascript">
>     
> document.getElementById('thelink').setAttribute('onclick', 'foo()');
> 
>     function foo() {
>         alert('foo');
>     }
> </script>
> ===

For browsers that get the DOM right, you use:

calImg.addEventListener("click", function() { drawCalendar('d', '0',
'0', this.name) }, true);

For IE, you use:

calImg.onclick=function() { drawCalendar('d', '0', '0', this.name) };

Don't ask me why. I still don't thoroughly get it myself:)

----------
Randal Rust
Covansys Corp.
Columbus, OH


More information about the thelist mailing list