返回到:Prototype – 元素对象
此方法滚动窗口,使元素出现在视口的顶部。
这与使用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">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<p id = "test">Click the button see the result.</p>
<input type = "button" value = "Click" onclick = "showResult();"/>
</body>
</html>返回到:Prototype – 元素对象
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/9014.html
支付宝
微信