Prevent Body From Scrolling on Touch Devices using jQuery
There are two scenarios I can think of when you might not want to the user to be able to scroll the window on handheld devices:
1. When a site is designed to fit within the boundaries of a viewport
2. When a fixed full screen menu or modal window has opened, in which case swiping up and down would cause the body content behind to continue to scroll.
Fortunately using jQuery we can prevent swiping by using something like so:
And to re-allow swiping again (i.e. when a menu or full screen modal is closed):