发布网友 发布时间:2022-04-23 04:23
共1个回答
热心网友 时间:2022-04-22 03:19
获取滚动条信息:
<script language="javascript">
if (document.documentElement && document.documentElement.scrollTop) {
t = document.documentElement.scrollTop;
l = document.documentElement.scrollLeft;
w = document.documentElement.scrollWidth;
h = document.documentElement.scrollHeight;
} else if (document.body) {
t = document.body.scrollTop;
l = document.body.scrollLeft;
w = document.body.scrollWidth;
h = document.body.scrollHeight;
}
</script>
获取文档信息:
<script language="javascript">
document.write(document.body.scrollWidth);
document.write("<p>");
document.write(document.body.scrollHeight);
document.write("<p>");
document.write(document.body.offsetWidth);
document.write("<p>");
document.write(document.body.offsetHeight);
document.write("<p>");
document.write(document.body.clientWidth);
document.write("<p>");
document.write(document.body.clientHeight);
</script>
我觉得当滚动条的top+height=文档的高度时就到底了吧
但网页开头都有<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">这句,引起误差...
希望可以帮到你。