FF和IE下的js兼容性问题  作者:w3pop.com 翻译/整理:w3pop.com FF和IE下的js兼容性问题


作者:w3pop.com 翻译/整理:w3pop.com 发布:2007-09-06 浏览:8894 :: FF和IE下的js兼容性问题  作者:w3pop.com 翻译/整理:w3pop.com :: FF和IE下的js兼容性问题  作者:w3pop.com 翻译/整理:w3pop.com

做了几周的js兼容性,多少总结了几条经验,下面把ff下常用的替代写法和区别列举出来,大家共享。
1,document.getElementById替代document.all(ie适用)

2,集合[]替代()(ie适用)

3,target替代srcElement;parentNode替代parentElement(parentNode ie适用)

4,node.parentNode.removeChild(node)替代removeNode(this)(ie适用)

5,有空白文本节点

6,无outerHTML属性

7,事件局部变量e替代事件全局变量event

8,e.button键值有别于event.button,只有3个键值而无组合键值

9,无ondrag事件

10,DOMMouseScroll替代onmousewheel;-e.detail替代event.wheelDelta

11,addEventListener替代attachEvent;removeEventListener替代detachEvent

12,e.preventDefault()替代event.returnValue=false;e.stopPropagation()替代event.cancelBubble=true

13,style.top、style.left等严格检查"px"单位(加"px" ie适用)

14,style="-moz-opacity:0.9"替代style="filter:alpha(opacity=90)";无其它filter

15,style.cursor="pointer"替代style.cursor="hand"(ie适用)

16,title替代alt(ie适用)

17,状态栏默认不可修改,需调整ff设置

18,内置绘图功能以canvas或者SVG替代vml

19,代码出错时经常不报错(想来也是ff的无奈之举吧,如果每个ie独有的表达方式换在它里面都报错的话,怕是报都报不过来吧)

20,对缓存的清理非常不好

注:标明“ie适用”者为通用性建议写法,未标明者在ie里不适用。

相关文章:

  • 2021-07-17
  • 2022-12-23
  • 2022-02-07
  • 2021-07-14
  • 2021-11-10
  • 2022-12-23
  • 2022-01-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-07
  • 2021-07-30
相关资源
相似解决方案