獲取網頁可見區域寬高(封裝免郵)
阿新 • • 發佈:2018-10-10
clas win ner lse view set cli rto 封裝
//獲取網頁可見區域寬高 function getViewPortOffset() { if(window.innerWidth) { return { w: window.innerWidth, h: window.innerHeight } } else { if(document.compatMode === "BackCompat") { //compatMode 用來確認是否關閉或開啟了標準兼容模式 //BackCompat:標準兼容模式關閉。 //CSS1Compat:標準兼容模式開啟。 return { w: document.body.clientWidth, h: document.body.clientHeight } } else { return { w: document.documentElement.clientWidth, y: document.documentElement.clientHeight } } } }
獲取網頁可見區域寬高(封裝免郵)