怎么获得当前DOCUMENT(比较长,出现滚动条)的从页头到页尾的高度? 滚动到底部再计算 clientHeight+scrollHeight 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 整个页面高度:document.body.scrollHeight显示区域高度:document.body.clientHeight 我试过了,SCROLLHEIGHT不是,只是当前滚屏到的高度。如果还没有滚动到底,那么就不是最后的高度。 楼主试的是什么?scrollHeight和滚动条滚动到哪没有关系。测试可以用下面的程序。楼主试的应该是scrollTop属性。<script language=javascript> function hehe() { alert(document.body.scrollHeight) }</script><input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> scrollHeight注意文档类型声明<!DOCTYPE ...>IE6加入了Strict模式后,将IE窗口模型的部分body属性重新定义为document.documentElemnt(html)属性。可加入如下代码判别,已兼容Transitional/Strict模式<SCRIPT LANGUAGE="JavaScript">window.onload = function(){window["viewport"] = (document.documentElement && document.documentElement.clientHeight)?document.documentElement:document.body;alert(viewport.scrollHeight)}</SCRIPT>IE/FF对于viewport对象解析略有不同,scrollHeight数值上有所差异 用jquery 实现 移动到表格的 某一行 就变背景颜色,请我怎么实现 ★JavaScript控制框架中的链接问题? js操作xml,向xml中添加一个节点 是不是所有能在ff里正常工作的js在ie里都能正常运行? 关于使用javascript write一个fomr 并提交的中文参数乱码问题 如何实现捕获某TD的坐标呢 请问如何获得前一个页面的对象,然后让其刷新 如何防止网页被人另存? 这段vbscript中错在那里? 关于日期的提问,高手答对者给分 关于由记录集生成的可编辑动态表格和更新记录集的问题 郁闷啊,一段简单的代码,为什么FF就是不兼容??
整个页面高度:document.body.scrollHeight显示区域高度:document.body.clientHeight
测试可以用下面的程序。
楼主试的应该是scrollTop属性。
<script language=javascript>
function hehe()
{
alert(document.body.scrollHeight)
}
</script>
<input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<input name=button1 type=button value="按" onclick="hehe()"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
IE6加入了Strict模式后,将IE窗口模型的部分body属性重新定义为document.documentElemnt(html)属性。可加入如下代码判别,已兼容Transitional/Strict模式<SCRIPT LANGUAGE="JavaScript">
window.onload = function(){
window["viewport"] = (document.documentElement && document.documentElement.clientHeight)?document.documentElement:document.body;
alert(viewport.scrollHeight)
}
</SCRIPT>IE/FF对于viewport对象解析略有不同,scrollHeight数值上有所差异