Prototype-element-scrollto
提供:Dev Guides
プロトタイプ-scrollTo()メソッド
このメソッドは、ビューポートの上部に要素が表示されるようにウィンドウをスクロールします。
これは、http://www.w3.org/TR/html401/struct/linksl#h-12.2.3 [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>