日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > web前端 > jscript > documentElement知識匯總

documentElement知識匯總

來源:程序員人生   發布時間:2014-03-03 10:55:41 閱讀次數:3180次
問題來源:
取得當前瀏覽器窗口的高度和寬度

解決文案:
<script type="text/javascript">
//from ppk (http://www.jr.pl/www.quirksmode.org/viewport/compatibility.html)
var x,y;
if (self.innerHeight) // all except Explorer
{
x = self.innerWidth;
y = self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientHeight)
// Explorer 6 Strict Mode
{
x = document.documentElement.clientWidth;
y = document.documentElement.clientHeight;
}
else if (document.body) // other Explorers
{
x = document.body.clientWidth;
y = document.body.clientHeight;
}
</script>

解決過程:
關于document.documentElement相關解釋:

w3c:This is a convenience attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".[譯:他是一個可以非常便捷的指向文檔的根結點元素,比如HTML文檔中指的是HTML標簽]
mozilla developer:Returns the Element that is the root element of the document (for example, the <html> element for HTML documents). [譯:返回文檔的根結點元素,如HTML文檔的<html>]
MSDN:Gets a reference to the root node of the document.[譯:獲取對瀏覽器的DOCUMENT元素的引用.(form MSDN中國)]

The CSSOM View Module節選并自己的譯文(翻譯不當之處,歡迎指正)

I have doubts about the WindowView interface, which contains ancient properties such as innerWidth.
我懷疑WindowView的接口,如他包含一些非常老的方法,如innerWidth.

The problem is that innerWidth/Height and pageXOffset/pageYOffset are essentially doubles: they report the same information as document.documentElement.clientWidth/Height and document.documentElement.scrollTop/Left: the inner width of the viewport (browser window) and the scrolling offset of the document.
問題是innerWidth/Height和pageXOffset/pageYOffset有雙重特性,document.documentElement.clientWidth/Height和document.documentElement.scrollTop/Left也給出了同樣的信息:瀏覽器內部窗口和文檔的滾動條偏移.

Since we already have that information available, why repeat it? The only reason would be that there might be situations where the documentElement does not span the entire viewport, but as far as I know these situations don't exist nowadays, and frankly I wonder if they'll ever exist.
既然我們得到了有效的信息,為何又要重復呢?這唯一的原因可能是解決documentElement不能跨越整個窗口,但據我所知這個問題今天已解決了,我還想知道是否他曾經就存在過這個問題.

I created a quick test that gives the root <html> element a wide margin and a border. Clicking outside the border still reports the <html> element as target, and document.documentElement.clientWidth and window.innerWidth report the same number of pixels in all browsers.
我做了一個示例,給標簽<html>增加了margin和border.單擊border外圍區域,同樣顯示<html>標簽存在,并且document.documentElement.clientWidth和 window.innerWidth在每個瀏覽器上都顯示同樣的像素大小.

So even though the root element may appear to cover only part of the viewport, JavaScript still acts as if it covers the entire viewport. That makes sense: there is no block-level element that contains the root element (or the root element wouldn't be the root element).
即使根元素可能覆蓋了窗口的一部分,他覆蓋整個窗口時,javascript依然顯示他的存在.那么結論是-沒有塊級元素能包含根元素.

The other properties of the window view, outerWidth/Height and screenX/Y, are mostly useless. They've been around since Netscape 3, and in the ten years I've been writing scripts I've never needed to use either of them.
window的其它屬性,outerWidth/Height和screenX/Y,基本上也是無效的.他在Netscape 3的時候用的非常廣泛,最近幾年我寫腳本的時候再也沒有用到他們了.

For al these reasons I'm wondering if the WindowView shouldn't be scrapped outright. It just serves no purpose.
因為一些其它原因我懷疑是不是應該廢棄WindowView呢.但這無濟于事!
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: av中文在线 | 精品一区二区在线视频 | 国产高清精品一区二区三区 | 国内精品久久久久久久影视简单 | 自拍偷拍福利视频 | 可以在线观看的av网站 | 精品一区二区三区在线视频 | 麻豆一区二区 | 成人久久网 | 亚洲综合二区 | 国产精品不卡视频 | 午夜精品 | 亚洲一区二区视频在线观看 | 久久久久久国产精品美女 | 中文日产幕无线码一二三四区 | 欧美激情精品久久久久久 | 国产精品高 | 色婷婷色综合 | a在线观看视频 | 国产日韩欧美 | 精品成人国产 | 欧美一区二区三区久久 | 美女激情网站 | 簧片免费在线观看 | 在线播放国产精品 | 国产a级大片 | 精品视频亚洲 | 国产精品美女久久久久aⅴ国产馆 | 亚洲看片 | 男女免费视频 | 天堂网avav| 国产精品成人av | 亚洲视频免费在线观看 | 精品一区久久久 | 国产免费专区 | 草av在线 | 久久久性 | 99精品欧美一区二区三区 | 色一乱一伦一图一区二区精品 | 在线看片日韩 | 日本视频黄色 |