Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

webview without scroll

Any way to prevent any scrolling within webview. I have an html page that is sized perfect; however, you are still able to scroll just a bit up and down (before it bounces back into place). Any thoughts?

— asked March 24th 2010 by Jim Nilson
  • no
  • scroll
  • webview

7 Answers

  • You could disable the bouncing effect with

    disableBounce = true;

    If you try to disable the touchmove or touched events you wont be able to scroll on the map anymore.

    — answered March 24th 2010 by Glenn Tillemans
    • the question was referring to a webview, the disableBounce property is only for ScrollView's

      — commented December 10th 2010 by Alberto Marcone
    • it worked for me on a webView

      — commented October 4th 2013 by Rick Hdz
  • This is for anyone that is stumbling across this very notion, but the problem isn't with any of the Titanium elements or the native webview, but rather the HTML that you're loading in.

    The solution is to simply set any possible padding and margins for the body and html tags to zero, as such:

    webview.setHtml("<html><head><style> html, body { margin: 0px; padding: 0px; } </style></head><body><script> alert('I am in a WebView'); </script></body></html>');

    Hope that helps!

    — answered April 12th 2013 by Haseeb Qureshi
  • Here is the solution.

    — answered October 19th 2012 by Sufian Babri
  • You should use preventDefault for "touchmove" and (maybe also) "touchend" events in your html page.

    — answered March 24th 2010 by Alexei Matveev
    1 Comment
    • For the benefit of others looking for the answer, this is not the right approach. As off 1.8.1 using e.preventDefault(); throws exceptions:

      Result of expression 'e.preventDefault' [undefined] is not a function.

      To achieve the same result without getting any exceptions add the following to the definition of your WebView…

      touchEnabled: false,

      — commented February 14th 2012 by Matthew Delmarter
  • @Glenn, could you please be more specific as to where to use disableBounce? I have not been able to find any information on this technique.

    — answered March 25th 2010 by Alexei Matveev
  • When I added:


    to the webview it worked but obviously any links, etc will not work, as touch is disabled.

    Hope that helps a little?

    — answered December 11th 2010 by Stephen Page
    1 Comment
    • Worked perfectly thanks.

      — commented February 14th 2012 by Matthew Delmarter
  • Use this, in the HTML:

    <meta name="viewport" content="width=320,initial-scale=1,maximum-scale=1.0,user-scalable=0" />

    — answered April 24th 2013 by Julio Omar Tellez Buendia
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.