在我电脑屏幕上显示的 电脑是 1920*1080这是在document.compatMode:css1Compat模式
window.screen.availWidth1920window.screen.availWidth1920window.screen.availHeight1057window.screen.width1920window.screen.height1080window.document.body.offsetHeight4901window.document.body.clientWidth1305document.body.clientHeight4901document.body.clientWidth1305document.documentElement.clientHeight460document.documentElement.clientWidth1305
现在是document.compatMode:BackCompat:页面没有!doctype声明
document.body.clientHeight460document.body.clientWidth1320document.documentElement.clientHeight460document.documentElement.clientWidth1320
以上红色部分就是说document.compatMode模式的区别下的网页可视区域的宽和高
so:
var height=document.compatMode='css1Compat':document.documentElement.clientHeight ? document.body.clientHeight;
if (document.compatMode == "BackCompat") {cWidth = document.body.clientWidth;cHeight = document.body.clientHeight;sWidth = document.body.scrollWidth;sHeight = document.body.scrollHeight;sLeft = document.body.scrollLeft;sTop = document.body.scrollTop;}else { //document.compatMode == "CSS1Compat"cWidth = document.documentElement.clientWidth;cHeight = document.documentElement.clientHeight;sWidth = document.documentElement.scrollWidth;sHeight = document.documentElement.scrollHeight;sLeft = document.documentElement.scrollLeft == 0 ? document.body.scrollLeft : document.documentElement.scrollLeft;sTop = document.documentElement.scrollTop == 0 ? document.body.scrollTop : document.documentElement.scrollTop;}
原标题:document.compatMode
关键词: