How do I modify the following code to detect scrolling to the top page instead.
window.onscroll = function(ev) {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
alert(bottom);
}
};
EDIT:
I am working on IE 10 for Windows Phone 8 BTW
Managed to figure it out. Here's my code
DEMO
worked for me
https://www.w3schools.com/jsref/event_onscroll.asp
The best way to do this with only JS is the following example adding an event listener:
its really simple:
window.scrollY
is not cross-browser according to MDN. On IE<9 you must checkdocument.body.scrollTop
, as no property ofwindow
will give you the current scroll position. Actually,document.body.scrollTop
is what I use most frequently, as in my experience it just works.