JavaScript Window screenTop Tutorial

In this section, we will learn what the Window screenTop property is and how to use it in JavaScript.

JavaScript Window screenTop Property

The `screenTop` property returns the distance between the top edge of the browser and the top side of the screen.

The return value of this property is pixel based. So if the value is 100, that means the distance is 100 pixels.

Note: if we maximize a browser window, the returned value of this property will be 0.

Also, this property is read-only.

Window screenTop Syntax:

window.screenTop

Example: using Window screenTop property in JavaScript

console.log(window.screenTop)

Output:

Depending on the current position of the browser window, the value of this property varies.

Leave a Reply