Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable scrolling on an iPad webapp?

Tags:

The usual:

document.body.addEventListener('touchmove',function(event){event.preventDefault();},false);  

isn't working for me. I am trying to make my iPad webapp feel as native as possible. Any answer is appreciated.

like image 714
Valli Avatar asked Oct 11 '11 23:10

Valli


People also ask

How do I disable scrolling on my website?

To hide the horizontal scrollbar and prevent horizontal scrolling, use overflow-x: hidden: HTML. CSS.

How do I turn off side scroll on iPhone?

Go to Settings and tap Accessibility. Turn on the feature, then use the slider to select a sensitivity level.


1 Answers

Put that handler on the document element directly, not on the body.

I've had success with the following:

<meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="format-detection" content="telephone=no"> 

Then with jQuery:

$(document).bind('touchmove', false); 

This will also be useful if you want to handle different orientations:

<link rel="stylesheet" type="text/css" href="css/main.css" media="all"> <link rel="stylesheet" type="text/css" href="css/landscape.css" media="all and (orientation:landscape)"> <link rel="stylesheet" type="text/css" href="css/portrait.css" media="all and (orientation:portrait)"> 
like image 141
Alnitak Avatar answered Sep 27 '22 21:09

Alnitak