I can't seem to capture the scroll event on an iPad. None of these work, what I am doing wrong?
window.onscroll=myFunction; document.onscroll=myFunction; window.attachEvent("scroll",myFunction,false); document.attachEvent("scroll",myFunction,false);
They all work even on Safari 3 on Windows. Ironically, EVERY browser on the PC supports window.onload=
if you don't mind clobbering existing events. But no go on iPad.
jQuery Mobile provides two scroll events: when scrolling starts and when scrolling stops.
The scroll event does not bubble up. Although the event does not bubble, browsers fire a scroll event on both document and window when the user scrolls the entire page.
The iPhoneOS does capture onscroll
events, except not the way you may expect.
One-finger panning doesn’t generate any events until the user stops panning—an
onscroll
event is generated when the page stops moving and redraws—as shown in Figure 6-1.
Similarly, scroll with 2 fingers fires onscroll
only after you've stopped scrolling.
The usual way of installing the handler works e.g.
window.addEventListener('scroll', function() { alert("Scrolled"); }); // or $(window).scroll(function() { alert("Scrolled"); }); // or window.onscroll = function() { alert("Scrolled"); }; // etc
(See also https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With