用javascript获取浏览器显示区域宽度和高度
//获取窗口宽度 if(window.innerWidth) winWidth = window.innerWinth; else if((document.body) && (document.body.clientWidth)) winWidth = document.body.clientWidth; //获取窗口高度 if(window.innerHeight) winHeight = window.innerHeight; else if((document.body) && (document.body.clientHeight)) winHeight = document.body.clientWidth; //通过深入document内部对body进行检测,获取窗口大小 if(document.documentElement && document.documentElement.clientHeight&&document.documentElement.clientWidth) { winHeight = document.documentElement.clientHeight; winWidth = document.documentElement.clientWidth; }
window.innerHeight
window.innerWidth
document.body.clientHeight
document.body.clientWidth
document.documentElement.clientHeight
document.documentElement.clientWidth
寻找爱