javascript兼容性问题

javascript常见的兼容问题整理:

1.滚动条:

document.documentElement.scrollTop  ||  document.body.scrollTop

2.获取样式兼容

function getStyle(dom,styleName){

return dorm.currentStyle?dom.currentStyle[styleName]

}

3.网页可视区域兼容

window.innerHeight || document.documentElement.clientHeight;

window.innerWidth || document.documentElement.clientWidth;

4.事件对象兼容

evt=evt||window.event;

5.阻止事件冒泡兼容

event.stopPropagation?event.stopPropagation():event.cancelBubble=true;

6.阻止默认行为兼容

evt.preventDefault?evt.preventDefault():evt.returnValue=false;

 

猜你喜欢

转载自www.cnblogs.com/manban/p/10881643.html