Javascript拖拽系列文章1之offsetParent屬性第1/3頁
更新時間:2008年09月22日 15:11:51 作者:
這個系列文章主要是講述實現(xiàn)Javascript拖拽功能的基礎知識,并將在最后給出一個完整的示例。適合對拖拽完全不懂的人閱讀
第一篇就先講講Javascript中的offsetParent屬性吧。
支持的瀏覽器:Internet Explorer 4.0+,Mozilla 1.0+,Netscape 6.0+,Opera 7.0+,Safari 1.0+
element.offsetParent
Summary
offsetParent returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element. If the element is non-positioned, the root element (html in standards compliant mode; body in quirks rendering mode) is the offsetParent. offsetParent returns null when the element has style.display set to "none".
Syntax
parentObj = element.offsetParent
Parameters
· parentObj is an object reference to the element in which the current element is offset.
Specification
DOM Level 0. Not part of specification.
節(jié)選自Mozilla Developer Center網(wǎng)站
翻譯如下:
element.offsetParent
總結
offsetParent屬性返回一個對象的引用,這個對象是距離調用offsetParent的元素最近的(在包含層次中最靠近的),并且是已進行過CSS定位的容器元素。 如果這個容器元素未進行CSS定位, 則offsetParent屬性的取值為根元素(在標準兼容模式下為html元素;在怪異呈現(xiàn)模式下為body元素)的引用。 當容器元素的style.display 被設置為 "none"時(譯注:IE和Opera除外),offsetParent屬性 返回 null 。
句法
parentObj = element.offsetParent
變量
· parentObj 是一個元素的引用,當前元素的偏移量在其中計算。
規(guī)范
DOM Level 0. 并非規(guī)范的一部分.
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
支持的瀏覽器:Internet Explorer 4.0+,Mozilla 1.0+,Netscape 6.0+,Opera 7.0+,Safari 1.0+
element.offsetParent
Summary
offsetParent returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element. If the element is non-positioned, the root element (html in standards compliant mode; body in quirks rendering mode) is the offsetParent. offsetParent returns null when the element has style.display set to "none".
Syntax
parentObj = element.offsetParent
Parameters
· parentObj is an object reference to the element in which the current element is offset.
Specification
DOM Level 0. Not part of specification.
節(jié)選自Mozilla Developer Center網(wǎng)站
翻譯如下:
element.offsetParent
總結
offsetParent屬性返回一個對象的引用,這個對象是距離調用offsetParent的元素最近的(在包含層次中最靠近的),并且是已進行過CSS定位的容器元素。 如果這個容器元素未進行CSS定位, 則offsetParent屬性的取值為根元素(在標準兼容模式下為html元素;在怪異呈現(xiàn)模式下為body元素)的引用。 當容器元素的style.display 被設置為 "none"時(譯注:IE和Opera除外),offsetParent屬性 返回 null 。
句法
parentObj = element.offsetParent
變量
· parentObj 是一個元素的引用,當前元素的偏移量在其中計算。
規(guī)范
DOM Level 0. 并非規(guī)范的一部分.
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁面才能執(zhí)行]
相關文章
深入理解JavaScript中為什么string可以擁有方法
下面小編就為大家?guī)硪黄钊肜斫釰avaScript中為什么string可以擁有方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05用js控件div的滾動條,讓它在內容更新時自動滾到底部的實現(xiàn)方法
下面小編就為大家?guī)硪黄胘s控件div的滾動條,讓它在內容更新時自動滾到底部的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-10-10指定區(qū)域的圖片自動按比例縮小的js代碼(防止頁面被圖片撐破)
有時候我們更新的內容,有很多的大圖片,就會導致頁面變形或看不到全圖。一般情況我們用css的max-width控制,但有些瀏覽器不支持,我們也可以用js做個補充2014-02-02JavaScript中使用document.write向頁面輸出內容實例
這篇文章主要介紹了JavaScript中使用document.write向頁面輸出內容實例,本文講解了輸出普通文字、帶HTML標簽內容的方法,需要的朋友可以參考下2014-10-10