今天查资料时无意发现一个以前没有注意到过的属性:document.compatmode
经过一番资料的查询后,了解到以下信息:
我们都知道IE有两种盒子模型,在不声明 !DOCTYPE 时是混杂模式 (Quirks Mode),在声明了 !DOCTYPE 时与其他标准浏览器一致,是标准模式 (Standards Mode)
document.compatMode 有两个属性值:
BackCompat ----- 表示标准规范模式关闭,即当前为混杂模式 (Quirks Mode),此时浏览器客户区宽度为 document.body.clientWidth
临沂奥硕软件有限公司拥有国内一流的企业网站管理系统,奥硕企业网站管理系统真正会打字就会建站的管理系统,其强大的扩展性可以满足企业网站实现各种功能(唯一集成3O多套模版的企业建站系统)奥硕企业网站管理系统具有一下特色功能1、双语双模(中英文采用单独模板设计,可制作中英文不同样式的网站)2、在线编辑JS动态菜单支持下拉效果,同时生成中文,英文,静态3个JS菜单3、在线制作并调用FLASH展示动画4、自
CSS1Compat ---- 表示标准规范模式开启,即当前为标准模式 (Standards Mode),此时浏览器客户区宽度为 document.documentElement.clientWidth
下面贴一份 准确获取网页客户区的宽高、滚动条宽高、滚动条Left和Top 的代码
1 if (document.compatMode == "BackCompat")
{ 2 cWidth = document.body.clientWidth; 3
cHeight = document.body.clientHeight; 4
sWidth = document.body.scrollWidth; 5 sHeight = document.body.scrollHeight; 6
sLeft = document.body.scrollLeft; 7 sTop = document.body.scrollTop; 8 }
else { //document.compatMode == "CSS1Compat" 9 cWidth = document.documentElement.clientWidth;10
cHeight = document.documentElement.clientHeight;11 sWidth = document.documentElement.scrollWidth;12
sHeight = document.documentElement.scrollHeight;13
sLeft = document.documentElement.scrollLeft == 0 ?
document.body.scrollLeft : document.documentElement.scrollLeft;14
sTop = document.documentElement.scrollTop == 0 ?
document.body.scrollTop : document.documentElement.scrollTop;15 }








