somehow addEventListener is not working for me. I am using following function. It shows me number of lines in the alert at line 8 but never says completed... Can anyone please tell the reason. I am using IE.
function load() {
var lnk = new Array();
lnk = document.getElementsByTagName("a");
var len = lnk.length;
alert('inside for..length is ..'+len);
for (var i=0;i<len;i++){
alert(i+" "+lnk[i]);
lnk[i].addEventListener('click',callMe,false);
alert('completed');
}
}
Internet Explorer doesn't support addEventListener until version 9. Previous versions use the proprietary attachEvent.
It is generally a good idea to use a library that abstracts browser differences (or a more general library such as YUI or jQuery).
Internet Explorer does not implement the "addEventListener()" API :-)
You can use attachEvent() in IE.
That is because each browser do it differently (thats the original reason js libraries where created).
Read this
IE uses element.attachEvent('onclick',doSomething)