function getViewport(){ if (document.compatMode == "BackCompat"){ return { width: document.body.clientWidth, height: document.body.clientHeight } } else { return { width: document.documentElement.clientWidth, height: document.documentElement.clientHeight } } }
//js 获取元素位置方法 getBoundingClientRect()
20180530_《Javascript获取网页大,元素位置(摘)》
原文:https://www.cnblogs.com/beesky520/p/9108711.html