【转】FireFox与IE js脚本差异 小结
生活随笔
收集整理的這篇文章主要介紹了
【转】FireFox与IE js脚本差异 小结
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. window.event IE:有window.event對象? FF:沒有window.event對象。可以通過給函數的參數傳遞event對象。如οnmοusemοve=doMouseMove(event) 2. 鼠標當前坐標 IE:event.x和event.y。? FF:event.pageX和event.pageY。? 通用:兩者都有event.clientX和event.clientY屬性。 3. 鼠標當前坐標(加上滾動條滾過的距離) IE:event.offsetX和event.offsetY。? FF:event.layerX和event.layerY。 4. 標簽的x和y的坐標位置:style.posLeft 和 style.posTop IE:有。? FF:沒有。? 通用:object.offsetLeft 和 object.offsetTop。 5. 窗體的高度和寬度 IE:document.body.offsetWidth和document.body.offsetHeight。注意:此時頁面一定要有body標簽。? FF:window.innerWidth和window.innerHegiht,以及 document.documentElement.clientWidth和 document.documentElement.clientHeight。? 通用:document.body.clientWidth和document.body.clientHeight。 6. 添加事件 IE:element.attachEvent("onclick", func);。? FF:element.addEventListener("click", func, true)。? 通用:element.οnclick=func。雖然都可以使用onclick事件,但是onclick和上面兩種方法的效果是不一樣的, onclick 只有執行一個過程,而attachEvent和addEventListener執行的是一個過程列表,也就是多個過程。例如: element.attachEvent("onclick", func1);element.attachEvent("onclick", func2)這樣func1和func2都會被執行。 7. 標簽的自定義屬性 IE:如果給標簽div1定義了一個屬性value,可以div1.value和div1["value"]取得該值。? FF:不能用div1.value和div1["value"]取。? 通用:div1.getAttribute("value")。 8. 父節點、子節點和刪除節點 IE:parentElement、parement.children,element.romoveNode(true)。? FF:parentNode、parentNode.childNodes,node.parentNode.removeChild(node)。 文章來源:http://blog.163.com/hongshaoguoguo@126/blog/static/1804698120125231075976/ by 獨行冰海
轉載于:https://www.cnblogs.com/GeekHacker/archive/2012/06/24/2560057.html
總結
以上是生活随笔為你收集整理的【转】FireFox与IE js脚本差异 小结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: urlrewrite 地址重写
- 下一篇: 手把手教你在ubuntu上安装LAMP