EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

scrollLeft property

Sets or retrieves the distance between the left edge of the object and the leftmost portion of the content currently visible in the window.

Syntax

JavaScript

p = object.scrollLeft

Property values

Type: Integer

the distance, in pixels.

0

Default value.

Remarks

This property's value equals the current horizontal offset of the content within the scrollable range. Although you can set this property to any value, if you assign a value less than 0, the property is set to 0. If you assign a value greater than the maximum value, the property is set to the maximum value.

You can set this property inline, but the results might be inconsistent while the document loads.

This property is always 0 for objects that do not have scroll bars. For these objects, setting the property has no effect.

When a marquee object scrolls vertically, its scrollLeft property is set to 0, overriding any script setting.

For more information about how to access the dimension and location of elements on the page, see Measuring Element Dimension and Location with CSSOM in Internet Explorer 9.

Examples

This example uses the scrollLeft property to determine the amount scrolled by the object.


<div id=oDiv style="position:absolute; width:200px; 
    height:100px; overflow:scroll"                   
    onclick=console.log(this.scrollLeft)>
    <span style="width:250px"> . . . </span>
</div>

See also

a
address
b
bdo
blockQuote
body
button
caption
cite
code
col
colGroup
custom
dd
dfn
div
dl
dt
em
embed
fieldSet
form
head
hn
html
i
img
input type=button
input type=checkbox
input type=email
input type=file
input type=image
input type=number
input type=password
input type=radio
input type=range
input type=reset
input type=search
input type=submit
input type=tel
input type=text
input type=url
kbd
label
legend
li
menu
meta
object
ol
option
p
pre
s
samp
script
select
small
span
strong
sub
sup
table
tBody
td
textArea
tFoot
th
tHead
tr
u
ul
var
Reference
scrollHeight
scrollTop
scrollWidth

 

 

Mostrar:
© 2014 Microsoft