首先,你的JavaScript只定义一个函数,并没有别的。
其次,你需要使用document.documentElement
(代表<html>
元素),而不是document.body
:
javascript:dh=document.documentElement.scrollHeight;ch=document.documentElement.clientHeight;if(dh>ch){moveme=dh-ch;window.scrollTo(0,moveme);}
,或者干脆
javascript:window.scrollTo(0,document.documentElement.scrollHeight)
(显然也没关系y-coord
的window.scrollTo
如果大于最大位置)。
更新:万一你必须在怪癖模式下处理IE,根元素的确是document.body
。其他浏览器让document.documentElement.clientHeight
代表文档的高度(请参阅Finding the size of the browser window,它处理窗口的高度,但包含一个漂亮的表格)。不管怎样,你要设置的滚动条来无论是最大的三个位置:
javascript:window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight))
真棒谢谢你 – matt 2010-06-07 05:11:58