火狐和IE浏览器的兼容问题汇总

1.window.event

code=(navigator.appName="Netscape")?event.which:event.keycode;

2.event.x

mx=event.x?event.x:event.pageX(火狐)

3.IE:event.srcElement  ;

Firefox:event.target;

4.cursor:hand(仅适用与IE); cursor:pointer;支持所有浏览器

5.innerText与textContent

if(navigator.appName.indexOf("Explorer")>-1){

document.getElementById("element").innerText="a";

}else{

document.getElementById("element").textContent="a";

}

6.padding:5px 4px 3px 2px;(火狐不支持,需分别设置)

7.XMLHTTP(XMLHttpRequest/ActiveXObject);

8.CSS hack:

①.css内部hack

IE6 IE7
+ IE7
- IE6
!important IE7 IE8 IE9 IE10 及其他浏览器
\9 IE系列浏览器
\0 IE8 IE9 IE10
\9\0

IE9 IE10

用法:selector{<hack>?property:value<hack>};

例:background-color:#0f0\9;

+background-color:#0f0;

②选择器hack(主要针对IE浏览器)

*html IE6
*+html IE7
:root IE9

用法:<hack>selector{  }

例::root .test{background-color:#0f0;}

③HTML头部引用(只能用在HTML文件里,只有在IE浏览器下才能执行)

lte 小于或等于
lt 小于
gte 大于或等于
gt 大于
不等于

例:<link rel="stylesheet" type="text/css" href="myCss.css"/>

<!-[if  lte IE9]>

<link rel="stylesheet" type="text/css" href="myIE.css"/>

<![endif]->

上一篇:在Salesforce中对某一个Object添加自定义的Button和Link


下一篇:Apache Spark源码走读之7 -- Standalone部署方式分析