小小小小yao

导航

火狐和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]->

 

posted on 2016-03-14 16:49  小小小小yao  阅读(346)  评论(0编辑  收藏  举报