DIV CSS 佈局教程網

IE 與 Firefox 的七個 JavaScript 相容差異
編輯:關於JavaScript     

IE 與 Firefox 在 JavaScript 中有不少差異。常見的例子包括:

  • float 樣式:IE 使用 styleFloat,Firefox 使用 cssFloat
  • 推算樣式:IE 使用 currentStyle,Firefox 使用 getComputedStyle
  • class 屬性:IE 需用 className,Firefox 可用 class
  • label for:IE 使用 htmlFor,Firefox 使用 for
  • 滑鼠座標:IE 常用 clientX,Firefox 常用 pageX
  • 視窗尺寸:IE 使用 documentElement.clientWidth,Firefox 使用 innerWidth
  • 透明度:IE 使用 filter alpha,Firefox 使用 opacity

實務上可透過功能偵測或封裝兼容函式,讓程式碼同時支援兩種瀏覽器。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved