Titanium Community Questions & Answer Archive

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

Prevent Double-Tap Zoom in Web View

I try to prevent the double-tap-to-zoom-function of a Web View but without losing all other (custom) events defined in the js of the webpage (like pinch to zoom, 2finger to scroll etc) .

As far as I know a double tap doesn’t generate any events (unlike touch touchstart/move/end). Is there a way to disable doubletapping directly in the js of the webpage loaded into the WebView?

Thank you!

— asked June 24th 2010 by Niko B
  • doubletap
  • ipad
  • iphone
  • prevent
  • webview
1 Comment
  • Have you found anything?

    — commented October 7th 2011 by Marc-André Benjamin

2 Answers

  • Just add the following meta tag in the <head> of your webView html code:

    <meta name="viewport" content="user-scalable=0">

    This will prevent the user from being able to zoom the page by doubletapping.

    — answered October 23rd 2011 by Sindre Sorhus
    • i have same problem, and this way is work, thank you~

      — commented December 20th 2011 by Winson Qiu
    • don't work on Android with Titanium 1.8.2

      — commented June 28th 2012 by max process
    • Max, it's fixed in Android in 2.0.2.

      — commented July 12th 2012 by Chris Dunstall
    • This answer does not work. Android 4.1; Appcelerator 2.1.4.GA

      — commented December 9th 2012 by Robert Dupuy
    • This doesn't work for me either. Besides, the user-scalable value should be "yes" or "no", not 0, so this isn't even valid html5.

      — commented December 10th 2012 by Justin Toth
    • weird, it still does not work on mine

      — commented May 29th 2013 by archileus tee
    • It really helps me too :) Thanks for sharing … :)

      — commented September 11th 2013 by Muhammad Burhan
    • +1 for Sharing …

      — commented September 11th 2013 by Muhammad Burhan
    • doesn't work with android

      — commented April 5th 2015 by Victor Oleksandrovich
  • You can add a listener to dblclick event in your web view. This prevents the default behavior of zoom in a web view

    webview.addEventListener(&#39;dblclick&#39;, function() { Titanium.API.info(&#39;dblclick in webview&#39;); });

    — answered July 10th 2013 by Almudena Vila
    • Doesn't work properly, if you click slow enough, so it won't be recognized as a doubleclick by Titanium, but fast enought to zoom, it still zooms in/out

      — commented September 12th 2013 by Intelly Developer
    • Just noticed the same Intelly, though the 'fix' is something. Found a better solution yet?

      — commented September 16th 2013 by Michiel D
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.