Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to prevent app running in phone-gap from scrolling vertically?
    primarykey
    data
    text
    <p>I'm trying out phone gap and I want my application to not scroll up and down when the user drags their finger across the screen. This is my code. Can anyone tell me why it's still allowing scrolling?</p> <pre><code> &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;meta name = "viewport" content = "user-scalable=no,width=device-width" /&gt; &lt;!--&lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /&gt;--&gt; &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8"&gt; &lt;!-- iPad/iPhone specific css below, add after your main css &gt; &lt;link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css" type="text/css" /&gt; &lt;link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" /&gt; --&gt; &lt;!-- If you application is targeting iOS BEFORE 4.0 you MUST put json2.js from http://www.JSON.org/json2.js into your www directory and include it here --&gt; &lt;script type="text/javascript" charset="utf-8" src="phonegap.0.9.5.1.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" charset="utf-8"&gt; // If you want to prevent dragging, uncomment this section /* function preventBehavior(e) { e.preventDefault(); }; document.addEventListener("touchmove", preventBehavior, false); */ /* If you are supporting your own protocol, the var invokeString will contain any arguments to the app launch. see http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html for more details -jm */ /* function handleOpenURL(url) { // TODO: do something with the url passed in. } */ function onBodyLoad() { document.addEventListener("deviceready",onDeviceReady,false); } /* When this function is called, PhoneGap has been initialized and is ready to roll */ /* If you are supporting your own protocol, the var invokeString will contain any arguments to the app launch. see http://iosdevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html for more details -jm */ function onDeviceReady() { // do your thing! navigator.notification.alert("PhoneGap is working") } touchMove = function(event) { // Prevent scrolling on this element event.preventDefault(); } &lt;/script&gt; &lt;style&gt; #container { width:100%; height:100%; } &lt;/style&gt; &lt;/head&gt; &lt;body onload="onBodyLoad()"&gt; &lt;div id="container" ontouchmove="touchMove(event);"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload