javascript - What exactly is stopping this script from working in IE8? (IE8 Issue) -
javascript not forte, found navigation script designed way want (jsfiddle below), cannot work ie8 (the best browser ever sarcasm).
please help!
window.onload = function () { var fine = [36, 34, 34, 34]; var mitms = document.getelementsbyclassname('mitm'); var l0 = (mitms[0].offsetleft + fine[0]); document.getelementbyid("nav_arrow").style.marginleft = l0 + "px"; (var = 0; < mitms.length; i++) { mitms[i].fine = fine[i]; mitms[i].onclick = function() { arr(this); var tmp = document.getelementsbyclassname('mitm'); } } }; function arr(el) { var mitms = document.getelementsbyclassname('mitm'); var l = el.offsetleft + el.fine; document.getelementbyid("nav_arrow").style.marginleft = l + "px"; }
you should not use default
variable name, reserved. use different name instead.
from documentation (7.6.1.1 keywords),
the following tokens ecmascript keywords , may not used identifiers in ecmascript programs:
break, do, instanceof, typeof, case else, new, var, catch, finally, return, void, continue, for, switch, while, debugger, function, this, with, default, if, throw, delete, in, try
edit: @crazytrain said, document.getelementsbyclassname
not supported. replace shim this:
function getelementsbyclassname(needle) { var my_array = document.getelementsbytagname("*"); var retvalue = new array(); var i; var j; (i=0,j=0;i<my_array.length;i++) { var c = " " + my_array[i].classname + " "; if (c.indexof(" " + needle + " ") != -1) retvalue[j++] = my_array[i]; } return retvalue; }
which call this:
var mitms = getelementsbyclassname('mitm');
Comments
Post a Comment