A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/HTMLElement/offsetTop below:

offsetTop · WebPlatform Docs

offsetTop

Property of dom/HTMLElementdom/HTMLElement

Syntax
var result = element.offsetTop;
element.offsetTop = value;
Examples

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

<html>

<head>
<script type="text/javascript">
function isinView(oObject)
{
    var oParent = oObject.offsetParent;
    var iOffsetTop = oObject.offsetTop;
    var iClientHeight = oParent.clientHeight;
    if (iOffsetTop > iClientHeight) {
        alert("Special Text not in view. Expand Window to put Text in View.");
    }
    else{
         alert("Special Text in View!");
    }
}
</script>
</head>

<body onload="window.resizeTo(430,250)" onclick="isinView(oID_1)" scroll="NO">

<div style="position: absolute; left: 20px">
    Click anywhere in window to see if special text is in view.</div>
<div id="oID_1" style="position: absolute;
    left: 50px;
    top: 300px;
    width: 280px;
    color: silver;
    font-size: large;
    font-weight: bold;
    background-color: aqua;
    font-family: Arial">
    Here&#39;s some special text </div>

</body>

</html>

View live example

Notes 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.

Syntax Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4