When CSS is used to hide scrollbar
html, body {
width: 100%;
overflow-x: hidden
}
The above code snippet removes the scroll from the window but triggers it on the body element. To calculate the scroll values in such cases, you can use:
pageOffset = (window.pageYOffset && { X: window.pageXOffset, Y: window.pageYOffset }) || {},
dElementOffset = (dE && { X: dE.scrollLeft, Y: dE.scrollTop }) || {},
dBodyOffset = (dB && { X: dB.scrollLeft, Y: dB.scrollTop }) || {};
[db stands for document.body and dE stands for document.documentElement]
If none of the above code snippets give the desired number of pixels scrolled, you can try finding a solution by visiting this link: http://jsbin.com/zayem/1/edit?html,css,js,console,output. You may need to load it in a separate HTML file, although the provided link is just for reference.