EN
Dieser Inhalt ist in Ihrer Sprache leider nicht verfügbar. Im Folgenden finden Sie die englische Version.

offsetLeft property

Retrieves the calculated left position of the object relative to the layout or coordinate parent, as specified by the offsetParent property.

Syntax

JavaScript

p = object.offsetLeft

Property values

Type: Integer

the left position, in pixels.

Remarks

You can determine the location, width, and height of an object by using a combination of the offsetLeft, offsetTop, offsetHeight, and offsetWidth properties. These numeric properties specify the physical coordinates and dimensions of the object relative to the object's offset parent.

For more information about how to access the dimension and location of objects on the page through the Dynamic HTML (DHTML) Document Object Model (DOM), see Measuring Element Dimension and Location with CSSOM in Internet Explorer 9.

Examples

This example uses the offsetLeft property to determine whether an object is in the user's view.


<script type="text/javascript">
function isinView(element) {
    var oparent = element.offsetParent; 
    var osleft = oID_1.offsetLeft;
    var cleft = oparent.clientWidth;
    if (osleft > cleft) {
        console.log("Expand the window to see the paragraph!");
    }
}
</script>
...
<button onclick="isinView(this)">Click here</button>
...
<div id="oID_1" style="position: absolute; top:200px; left:1200px;">
...
</div>

See also

a
abbr
address
area
b
bdo
blockQuote
body
br
button
caption
cite
code
col
colGroup
custom
dd
del
dfn
div
dl
dt
em
embed
fieldSet
form
frame
hn
hr
i
iframe
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
ins
kbd
label
legend
li
map
menu
object
ol
option
p
pre
q
rt
ruby
s
samp
select
small
span
strong
sub
sup
table
tBody
td
textArea
TextRange
tFoot
th
tHead
tr
u
ul
var
Reference
boundingHeight
boundingLeft
boundingTop
boundingWidth

 

 

Anzeigen:
© 2014 Microsoft