JavaScript Reference/Javascript Properties/scrollLeft

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

"scrollLeft" Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
    mySL.innerHTML = myDiv.scrollLeft;
    myST.innerHTML = myDiv.scrollTop; 
} 
</script>
<p>
   <b>Scroll Left:</b> 
   <span id="mySL">0</span>
</p>
<p>
   <b>Scroll Top:</b> 
   <span id="myST">0</span>
</p>
<div id="myDiv" 
     onmousemove="function2();" 
     onscroll="function1();" 
     style="border:solid; width:200; height:50; overflow:scroll;">
   <img src="yourimage.gif">
</div>
</body>
</html>



"scrollLeft" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<a>                             <acronym>                     |
|                |<address>                       <applet>                      |
|                |<area>                          <b>                           |
|                |<base>                          <basefont>                    |
|                |<bdo>                           <big>                         |
|                |<blockquote>                    <body>                        |
|                |<br>                            <button>                      |
|                |<caption>                       <center>                      |
|                |<cite>                          <code>                        |
|                |<col>                           <colgroup>                    |
|                |<custom>                        <dd>                          |
|                |<del>                           <dfn>                         |
|                |<dir>                           <div>                         |
|                |<dl>                            <dt>                          |
|                |<em>                            <embed>                       |
|                |<fieldset>                      <form>                        |
|                |<frame>                         <frameset>                    |
|                |<head>                          <hn>                          |
|                |<hr>                            <html>                        |
|                |<i>                             <iframe>                      |
|                |<img>                           <input>                       |
|                |<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">             <ins>                         |
|                |<isindex>                       <kbd>                         |
|                |<label>                         <legend>                      |
|                |<li>                            <link>                        |
|                |<listing>                       <map>                         |
|                |<marquee>                       <menu>                        |
|                |<meta>                          <nobr>                        |
|                |<noframes>                      <noscript>                    |
|                |<object>                        <ol>                          |
|                |<optgroup>                      <option>                      |
|                |<p>                             <param>                       |
|                |<plaintext>                     <pre>                         |
|                |<q>                             <s>                           |
|                |<samp>                          <script>                      |
|                |<select>                        <small>                       |
|                |<span>                          <strike>                      |
|                |<strong>                        <style>                       |
|                |<sub>                           <sup>                         |
|                |<table>                         <tbody>                       |
|                |<td>                            <textarea>                    |
|                |<tfoot>                         <th>                          |
|                |<thead>                         <title>                       |
|                |<tr>                            <tt>                          |
|                |<u>                             <ul>                          |
|                |<var>                           <xmp>                         |
+----------------+--------------------------------------------------------------+



"scrollLeft" Syntax and Note

Note:
Read-only properties. 
    
Syntax:
    
document.all.getElementById("elementID").scrollLeft
document.all.elementID.scrollLeft // IE only
document.all.getElementById("elementID").scrollTop
document.all.elementID.scrollTop // IE only