Javascript拖拽&拖放系列文章1之offsetParent属性
这个系列文章主要是讲述实现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.
节选自Mozilla Developer Center网站
翻译如下:
element.offsetParent
总结
offsetParent属性返回一个对象的引用,这个对象是距离调用offsetParent的元素最近的(在包含层次中最靠近的),并且是已进行过CSS定位的容器元素。 如果这个容器元素未进行CSS定位, 则offsetParent属性的取值为根元素(在标准兼容模式下为html元素;在怪异呈现模式下为body元素)的引用。 当容器元素的style.display 被设置为 "none"时(译注:IE和Opera除外),offsetParent属性 返回 null 。
句法
parentObj = element.offsetParent
变量
· parentObj 是一个元素的引用,当前元素的偏移量在其中计算。
规范
DOM Level 0. 并非规范的一部分.
测试代码1:
<!DOCTYPE&nb
相关文档:
ugmbbc发布于 2009-11-14 09:41:43| 7628 次阅读 字体:大 小 打印预览
var ReTitle = '回复:Google 排名中的 10 个最著名的 JavaScript 库';
感谢COMSHARP CMS的投递
新闻来源:tripwiremagazine.com
JavaScript 是 Web 开发与设计中不可或缺的东西,不管是一个简单的网页还是一个专业的站点,也不管你是高手还是菜鸟 ......
javascript面向对象继承的三种方法:
<
html xmlns
=
"
http://www.w3.org/1999/xhtml
"
>
<
head runat
=
"
server
"
>
<
title
>
Untitled Page
</
title ......
这种新式的技术最先由jQuery搞出来的,接着Prototype与mootools都支持了。这技术兴起的原因是浏览器嗅探技术是不太可靠,如UserAgent很容易被伪造,如IE8的UserAgent就把许多浏览器的关键字包含进去,造成辩识困难。其他一些重要辩识手段,由于浏览器厂商对旧版本的升级与不断推进新版本,许多都无效了。由于浏览器种类越来 ......
2 封装
下面我们就来讨论具体的封装。首先说一下大家最熟悉的几种封装:私有实例成员、公有实例成员和公有静态成员。最后会讨论一下大家所不熟悉的私有静态成员和静态类的封装办法。因为下面要讨论的是面向对象编程,所有当函数作为类来定义和使用时,我们暂且将其成为类。
2.1 私有实例成员
私有实例成员在 JavaScript ......