Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get top position of the web page using javascript

Trying to take position of the top (window top x=0 and y=0) visible part of the web page.

Please see this image

enter image description here

like image 210
manna Avatar asked Jan 18 '26 14:01

manna


2 Answers

You need:

 $(window).scrollTop();

Using Javascript:

 document.documentElement.scrollTop  ||  window.pageYOffset

Working Fiddle

like image 84
Milind Anantwar Avatar answered Jan 20 '26 02:01

Milind Anantwar


Common:

var X - $(window).screenX();
var Y - $(window).screenY();

IE:

var X = $(window).screenLeft();
var Y - $(window).screenTop();

Hope it helps you!

like image 29
immayankmodi Avatar answered Jan 20 '26 02:01

immayankmodi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!