dom scrollX scrollY innerWidth cilentWidth
作者:互联网
function getScroll(){ return { x:window.pageXOffset?window.pageXOffset:document.body.scrollLeft+document.documentElement.scrollLeft, y:window.pageYOffset?window.pageYOffset:document.body.scrollTop+document.documentElement.scrollTop, } }
function getViewportWH(){ if(window.innerWidth){ return { w:window.innerWidth, h:window.innerHeight, } }else{ if(document.compatMode==='BackCompat'){ return { w:document.body.clientWidth, h:document.body.clientHeight, } }else{ return { w:document.documentElement.clientWidth, h:document.documentElement.clientHeight, } } } } console.log(getViewportWH())
标签:body,return,documentElement,innerWidth,scrollY,window,cilentWidth,document 来源: https://www.cnblogs.com/howhy/p/15796892.html