document.compatMode
2016-08-19 14:19
393 查看
在我电脑屏幕上显示的 电脑是 1920*1080这是在document.compatMode:css1Compat模式
window.screen.availWidth 1920 window.screen.availWidth 1920 window.screen.availHeight 1057 window.screen.width 1920 window.screen.height 1080 window.document.body.offsetHeight 4901 window.document.body.clientWidth 1305 document.body.clientHeight 4901 document.body.clientWidth 1305 document.documentElement.clientHeight 460 document.documentElement.clientWidth 1305
现在是document.compatMode:BackCompat:页面没有!doctype声明
document.body.clientHeight 460 document.body.clientWidth 1320 document.documentElement.clientHeight 460 document.documentElement.clientWidth 1320
以上红色部分就是说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; }
相关文章推荐
- javascript document.compatMode介绍
- Javascript中的文档模式-document.compatMode
- 【转】js中的文档模式-document.compatMode
- 前端面霸系列(1):doctype 、Quirks Mode & Standards Mode 、document.compatMode
- 利用document.compatMode写出更兼容的JS
- document.compatMode的CSS1compat
- document.documentElement和document.body 与document.compatMode的关系
- document.body和document.documentElement,document.compatMode的关系
- document.compatMode 浏览器渲染模式判定利器
- document.compatMode属性
- document.compatMode属性
- javascript document.compatMode兼容性
- document.compatMode 记录
- document.compatMode属性
- document.compatMode
- document.compatMode的CSS1compat使用介绍
- document.compatMode介绍
- document.compatMode介绍
- 关于document.compatMode的一些介绍
- document.compatMode的CSS1compat使用介绍