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())