JavaScript Reference/Javascript Methods/scrollIntoView — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:22, 26 мая 2010

"scrollIntoView()" Example

    
<html>
<body>
<script language="JavaScript">
    function function1(){
        document.all.myDiv.scrollIntoView(true);
    }
    function function2(){
        window.scrollTo(0,0);
    }
</script>
<input type="button" value=" Scroll to the myDiv" onClick="function1();">
<div style="height:1000;background-color:blue;"></div>
<div id=myDiv onclick="function2();">
This is the element scrolled into view. Click here to go to top.
</div>
</body>
</html>



"scrollIntoView()" is applied to

Names noted with an asterisk (*) are JavaScript properties only.
+----------------+--------------------------------------------------------------+
| Applied_To     |<a>                             <address>                     |
|                |<applet>                        <area>                        |
|                |<b>                             <big>                         |
|                |<blockquote>                    <br>                          |
|                |<button>                        <caption>                     |
|                |<center>                        <cite>                        |
|                |<code>                          <col>                         |
|                |<colgroup>                      <comment>                     |
|                |controlRange*                   <custom>                      |
|                |<dd>                            <dfn>                         |
|                |<dir>                           <div>                         |
|                |<dl>                            <dt>                          |
|                |<em>                            <embed>                       |
|                |<fieldset>                      <font>                        |
|                |<form>                          <hn>                          |
|                |<hr>                            <i>                           |
|                |<iframe>                        <img>                         |
|                |<input type="button">           <input type="checkbox">       |
|                |<input type="file">             <input type="image">          |
|                |<input type="password">         <input type="radio">          |
|                |<input type="reset">            <input type="submit">         |
|                |<input type="text">             <kbd>                         |
|                |<label>                         <legend>                      |
|                |<li>                            <listing>                     |
|                |<map>                           <marquee>                     |
|                |<menu>                          <nobr>                        |
|                |<object>                        <ol>                          |
|                |<p>                             <plaintext>                   |
|                |<pre>                           <s>                           |
|                |<samp>                          <select>                      |
|                |<small>                         <span>                        |
|                |<strike>                        <strong>                      |
|                |<sub>                           <sup>                         |
|                |<table>                         <tbody>                       |
|                |<td>                            <textarea>                    |
|                |TextRange                       <tfoot>                       |
|                |<th>                            <thead>                       |
|                |<tr>                            <tt>                          |
|                |<u>                             <ul>                          |
|                |<var>                           <wbr>                         |
|                |<xmp>                                                         |
+----------------+--------------------------------------------------------------+



"scrollIntoView()" Syntax, Parameters and Note

Note:
Scrolls the window until the element is visible.
    
Syntax:
    
document.all.elementID.scrollIntoView(param1)
Parameters:
    param1   Optional; true or false, indicating whether the top of the element 
                       is scrolled to the top of the window or the bottom of the 
                       element is scrolled to the bottom of the window.