mobile-safari ios - ipad safari:disable scrolling, and bounce effect?

overscroll prevent (11)

You can use js for prevent scroll:

let body = document.body;

let hideScroll = function(e) {

function toggleScroll (bool) {

  if (bool === true) {
    body.addEventListener("touchmove", hideScroll);
  } else {
    body.removeEventListener("touchmove", hideScroll);

And than just run/stop toggleScroll func when you opnen/close modal.

Like this toggleScroll(true) / toggleScroll(false)

(This is only for iOS, on Android not working)

I'm working on a browser based app, currently I'm developing and styling for the ipad safari browser.

I'm looking for two things on the ipad: How can I disable vertical scrolling for pages that don't require it? & how can I disable the elastic bounce effect?

To prevent scrolling on modern mobile browsers you need to add the passive: false. I had been pulling my hair out getting this to work until I found this solution. I have only found this mentioned in one other place on the internet.

function preventDefault(e){

function disableScroll(){
    document.body.addEventListener('touchmove', preventDefault, { passive: false });
function enableScroll(){
    document.body.removeEventListener('touchmove', preventDefault, { passive: false });

For those who are using MyScript the Web App and are struggling with the body scrolling/dragging (on iPad and Tablets) instead of actually writing:

<body touch-action="none" unresolved>

That fixed it for me.

Try this JS sollutuion:

var xStart, yStart = 0; 

document.addEventListener('touchstart', function(e) {
    xStart = e.touches[0].screenX;
    yStart = e.touches[0].screenY;

document.addEventListener('touchmove', function(e) {
    var xMovement = Math.abs(e.touches[0].screenX - xStart);
    var yMovement = Math.abs(e.touches[0].screenY - yStart);
    if((yMovement * 3) > xMovement) {

Prevents default Safari scrolling and bounce gestures without detaching your touch event listeners.

I know this is slightly off-piste but I've been using Swiffy to convert Flash into an interactive HTML5 game and came across the same scrolling issue but found no solutions that worked.

The problem I had was that the Swiffy stage was taking up the whole screen, so as soon as it had loaded, the document touchmove event was never triggered.

If I tried to add the same event to the Swiffy container, it was replaced as soon as the stage had loaded.

In the end I solved it (rather messily) by applying the touchmove event to every DIV within the stage. As these divs were also ever-changing, I needed to keep checking them.

This was my solution, which seems to work well. I hope it's helpful for anyone else trying to find the same solution as me.

var divInterval = setInterval(updateDivs,50);
function updateDivs(){
$("#swiffycontainer > div").bind(
     function(e) {

Similar to angry kiwi I got it to work using height rather than position:

html,body {
  height: 100%;
  overflow: hidden;

  -webkit-overflow-scrolling: touch;

You can also change the position of the body/html to fixed:

html {
  position: fixed;

2011 answer: For a web/html app running inside iOS Safari you want something like

document.ontouchmove = function(event){

For iOS 5 you may want to take the following into account: document.ontouchmove and scrolling on iOS 5

Update September 2014: A more thorough approach can be found here: For that and a whole lot of useful webapp advice, see

Update March 2016: That last link is no longer active - see for the archived version instead. Thanks @falsarella for pointing that out.

It only opens the first (bookmarked) page full screen. Any next page will be opened WITH the address bar visible again. Whatever meta tag you put into your page header...

ipad scroll mobile-safari bounce