IE,FF等浏览器兼容性问题

_1:改变选中时候的背景色处理:

::selection {
color:#fff;
background-color: #5CB85C ;
}

 

::-moz-selection {
color:#fff;
background-color: #5CB85C ;
}

 

::-webkit-selection {
color:#fff;
background-color: #5CB85C ;
}

 

 

_2:解决IE不支持fixed的办法:

background-image: url(about:blank); /* 使用空背景 */
background-attachment: fixed; /* 固定背景 */

 

给个空背景,然后让背景固定即可

 

1.HTML对象获取问题

  FireFox:document.getElementById(“idName”);

  IE:document.idname或者document.getElementById(“idName”).

  解决办法:统一使用document.getElementById(“idName”);

2.const问题

  说明:Firefox下,可以使用const关键字或var关键字来定义常量;

  IE下,只能使用var关键字来定义常量.

  解决方法:统一使用var关键字来定义常量.

3.event.x与event.y问题

  说明:IE下,event对象有x,y属性,但是没有pageX,pageY属性;

  Firefox下,event对象有pageX,pageY属性,但是没有x,y属性.

  解决方法:使用mX(mX   =   event.x   ?   event.x   :   event.pageX;)来代替IE下的event.x或者Firefox下的event.pageX.

4.window.location.href问题

  说明:IE或者Firefox2.0.x下,可以使用window.location或window.location.href;

  Firefox1.5.x下,只能使用window.location.

  解决方法:使用window.location来代替window.location.href.

5.frame问题

以下面的frame为例:

<frame  src=”xxx.html”  id=”frameId”  name=”frameName”  />

(1)访问frame对象:

  IE:使用window.frameId或者window.frameName来访问这个frame对象.frameId和frameName可以同名。

  Firefox:只能使用window.frameName来访问这个frame对象.

  另外,在IE和Firefox中都可以使用window.document.getElementById(“frameId”)来访问这个frame对象.

(2)切换frame内容:

  在 IE和Firefox中都可以使用window.document.getElementById(“testFrame”).src   =   “xxx.html”或window.frameName.location   =   “xxx.html”来切换frame的内容.

  如果需要将frame中的参数传回父窗口(注意不是opener,而是parent   frame),可以在frame中使用parent来访问父窗口。例如:parent.document.form1.filename.value=”Aqing”;

posted @ 2020-07-17 11:49  lpmou  阅读(224)  评论(0编辑  收藏  举报
返回顶部