关于HTML DOM

s546489791 2011-10-27 02:20:25
在HTML DOM模型中,节点没有offsetWidth、clientWidth、属性,为什么却可以再js中调用呢?
...全文
88 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
挨踢直男 2011-10-27
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 s546489791 的回复:]

如何能获得窗口可见界面的高度,就是最后一个工具条以下到状态栏以上的高度??谢谢了
[/Quote]

function getScreenSize(target)
{
var theWidth,theHeight;
if (target.innerWidth)
{
theWidth = target.innerWidth
theHeight = target.innerHeight
}
else if (target.document.compatMode=='CSS1Compat')
{
theWidth = target.document.documentElement.clientWidth
theHeight = target.document.documentElement.clientHeight
}
else if (target.document.body)
{
theWidth = target.document.body.clientWidth
theHeight = target.document.body.clientHeight
}
var result = [theWidth,theHeight];
return result;
}

var width = getScreenSize(window)[0];
var height=getScreenSize(window)[1];
alert("宽:"+width+",高:"+height);
明悟 2011-10-27
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 s546489791 的回复:]
非常感谢大侠们的积极帮助,再次感谢,,

还有个一个问题是:为什么 document.body.offsetHeight 和 document.body.clientHeight得出值是一样的啊?
[/Quote]
你把body的border属性设置大于0,就会发现他们的不同了
s546489791 2011-10-27
  • 打赏
  • 举报
回复
如何能获得窗口可见界面的高度,就是最后一个工具条以下到状态栏以上的高度??谢谢了
s546489791 2011-10-27
  • 打赏
  • 举报
回复
非常感谢大侠们的积极帮助,再次感谢,,

还有个一个问题是:为什么 document.body.offsetHeight 和 document.body.clientHeight得出值是一样的啊?
打字员 2011-10-27
  • 打赏
  • 举报
回复
HTML DOM 指的是文档模型,只表示数据结构。

offsetWidth、clientWidth是页面渲染后的视觉呈现(大小,位置,颜色,状态等)
liangws 2011-10-27
  • 打赏
  • 举报
回复
他们是通过接口来实现的
hp2008001 2011-10-27
  • 打赏
  • 举报
回复
hookee 2011-10-27
  • 打赏
  • 举报
回复
这些是DOM节点的property。 不是 HTML标签的 attribute

87,921

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧