欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

document.documentElement和document.body區(qū)別介紹

 更新時(shí)間:2013年09月16日 10:52:22   作者:  
body是DOM對(duì)象里的body子節(jié)點(diǎn),即body標(biāo)簽,documentElement 是整個(gè)節(jié)點(diǎn)樹(shù)的根節(jié)點(diǎn)root,詳細(xì)介紹請(qǐng)看本文,感興趣的朋友可以參考下
區(qū)別:

body是DOM對(duì)象里的body子節(jié)點(diǎn),即 <body> 標(biāo)簽;
documentElement 是整個(gè)節(jié)點(diǎn)樹(shù)的根節(jié)點(diǎn)root,即<html> 標(biāo)簽;

沒(méi)使用DTD情況即怪異模式BackCompat下:
復(fù)制代碼 代碼如下:

document.documentElement.clientHeight=0document.body.clientHeight=618

使用DTD情況即標(biāo)準(zhǔn)模式CSS1Compat下:
復(fù)制代碼 代碼如下:

document.documentElement.clientHeight=618 document.body.clientHeight=28(表示內(nèi)容的高度)

因此提取瀏覽器的尺寸是要注意了??梢詤⒖家韵麓a:
復(fù)制代碼 代碼如下:

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;
}

相關(guān)文章

最新評(píng)論