JS: style.top style.left 在IE和FireFox的区别

       ie6-ie8可使用可以直接用obj.style.top=100; 但在FireFox和ie9中必须加上单位,变成obj.style.top=100+'px'; style.left同理。

       浏览器的判断:window.navigator.userAgent.indexOf("IE") == -1 // 非IE浏览器  FireFox,Chrome

       FireFox 没有onmouseover和onmouseout,onclick事件,他们的写法为:

       if (window.navigator.userAgent.indexOf("IE") == -1)  {       // FireFox
              link.addEventListener('mouseover', function(){a = false}, true);
              link.addEventListener("mouseout",function(){a = true},true)
       } else {       // IE
              link.attachEvent("onmouseover",function(){a = false});
              link.attachEvent("onmouseout",function(){a = true});
       }

你可能感兴趣的:(function,浏览器,IE,chrome,firefox)