Prototype - scrollTo() 方法
此方法滚动窗口,使元素出现在视口顶部。
这与使用 HTML 锚点 实现的效果类似(除了浏览器的历史记录不会被修改)。
语法
element.scrollTo();
返回值
返回 HTML 元素。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
$('heading').scrollTo();
}
</script>
</head>
<body">
<h1 id = "heading">This is the heading.</h1>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<p id = "test">点击按钮查看结果。</p>
<input type = "button" value = "Click" onclick = "showResult();"/>
</body>
</html>

prototype_element_object.html