關於JS的瀏覽器兼容1

1、阻止默認行爲

// 非 ie 和 ie 

if(e.preventDefault){e.preventDefault();}else{return value = false;}

2、阻止冒泡

if(e.stopPropagation){e.Propagation()}else{e.cancelBubble = true;}

3、獲取style樣式

if(window.getComputedStyle){window.getComputedStyle();}{return obj.curretnStyle();}

4、事件對象

e = e || event;

5、隱藏高度

scrolltop = document.documentElement.scrollTop || document.body.scrollTop;


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章