Skip to content Skip to sidebar Skip to footer

Measuring The Window Offset

Is there a way to measure the offset of the window in jQuery, in order than I might compare the positions of a 'fixed' element and a relatively positioned one? I need to be able to

Solution 1:

$(window).scrollTop() and $(window).scrollLeft() can be used to find scroll positions.

Solution 2:

Using plain Javascript without jQuery should be window.pageXOffset and window.pageYOffset, which return the number of pixels offset by scrolling.

Source: https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY

Solution 3:

document.body.offsetWidth;

and

document.body.offsetHeight;

By using these javascript functions you can get actual width and height of the browser window

Post a Comment for "Measuring The Window Offset"