Disable scrolling in all mobile devices
html, body {
overflow-x: hidden;
}
body {
position: relative;
}
The position relative is important, and i just stumbled about it. Could not make it work without it.
cgvector answer didn't work for me, but this did:
document.body.addEventListener('touchstart', function(e){ e.preventDefault(); });
I wouldn't leave it just like that, a smarter logic is needed to select when to prevent the scrolling, but this is a good start.
Taken from here: Disable scrolling in an iPhone web application?
For future generations:
To prevent scrolling but keep the contextmenu, try
document.body.addEventListener('touchmove', function(e){ e.preventDefault(); });
It still prevents way more than some might like, but for most browsers the only default behaviour prevented should be scrolling.
For a more sophisticated solution that allows for scrollable elements within the nonscrollable body and prevents rubberband, have a look at my answer over here:
https://stackoverflow.com/a/20250111/1431156