element.ownerDocument,document.defaultView以及document.documentElement

1.element.ownerDocument

以 Document 对象的形式返回元素element的 owner document

http://www.w3school.com.cn/jsref/dom_obj_all.asp


2.Document.defaultView-----这是一个只读属性。

在浏览器中返回关联document的window对象,如果没有则返回null
用法:
var win = document.defaultView;

注意:

在怪异模式(quick mode)下, IE 9 以下版本不支持defaultView.

当使用Firefox 3.6时,其frame中需要使用document.defaultView去获取window对象


3.document.documentElement

document.body是DOM中Document对象里的body节点, document.documentElement是文档对象根节点(html)的引用。
     IE在怪异模型(quick mode)下document.documentElement无法正确取到clietHeight scrollHeight等值,比如clietHeight=0。可以见IE的怪异模型并没有把html作为盒子模型的一部分,好在现在很少使用怪异模型。(注:如果页面没写DTD或写的不对,IE6默认使用怪异模型解析页面)

document.body.scrollHeight和document.documentElement.scrollHeight的区别:

     document.body.scrollHeight是body元素的滚动高度,document.documentElement.scrollHeight为页面的滚动高度,且 document.documentElement.scrollHeight在IE和Firefox下还有点小差异。
     IE : document.documentElement.scrollHeight = document.body.scrollHeight + marginTop bottom高度 + 上下border宽度
     firefox : document.documentElement.scrollHeight = document.body.scrollHeight + marginTop bottom高度


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值