JavaScript Reference/Javascript Methods/scrollIntoView

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

"scrollIntoView()" Example

   <source lang="javascript">
   

<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();">

This is the element scrolled into view. Click here to go to top.

</body> </html>


     </source>
   
  


"scrollIntoView()" is applied to

   <source lang="javascript">

Names noted with an asterisk (*) are JavaScript properties only. +----------------+--------------------------------------------------------------+ | Applied_To |<a> <address> | | |<applet> <area> | | | |

| |

|

| |<button> |

| |
|

| | <col> | | |<colgroup> <comment> | | |controlRange* <custom> | | |

|

| |<dir>
| | |
| | | <embed> | | |<fieldset> | | |<form> <hn> | | |
|

| |<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"> | | |<label> <legend> |

| |
  • <listing> | | |<map> <marquee> | | |<menu> <nobr> | | |<object>
      | | |

      <plaintext> | | |

                                                            |
      |                |                          <select>                      |
      |                |                                                 |
      |                |                                              |
      |                |                                                    |
      |                |                         <tbody>                       |
      |                |                          |
      |                |                             
        | | | | | |<xmp> | +----------------+--------------------------------------------------------------+ </source>

        "scrollIntoView()" Syntax, Parameters and Note

        <source lang="javascript"> 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.


        </source>

      <textarea> |

      | |TextRange <tfoot> |

      | |
      <thead> | | |