Disable double-tap “zoom” option in browser on touch devices

后端 未结 14 1354
-上瘾入骨i
-上瘾入骨i 2020-11-28 02:58

I want to disable the double-tap zoom functionality on specified elements in the browser (on touch devices), witho

14条回答
  •  独厮守ぢ
    2020-11-28 03:46

    I assume that I do have a

    input container area with text, sliders and buttons in it, and want to inhibit accidental double-taps in that
    . The following does not inhibit zooming on the input area, and it does not relate to double-tap and zooming outside my
    area. There are variations depending on the browser app.

    I just tried it.

    (1) For Safari on iOS, and Chrome on Android, and is the preferred method. Works except for Internet app on Samsung, where it disables double-taps not on the full

    , but at least on elements that handle taps. It returns return false, with exception on text and range inputs.

    $('selector of 
    input area').on('touchend',disabledoubletap); function disabledoubletap(ev) { var preventok=$(ev.target).is('input[type=text],input[type=range]'); if(preventok==false) return false; }

    (2) Optionally for built-in Internet app on Android (5.1, Samsung), inhibits double-taps on the

    , but inhibits zooming on the
    :

    $('selector of 
    input area').on('touchstart touchend',disabledoubletap);

    (3) For Chrome on Android 5.1, disables double-tap at all, does not inhibit zooming, and does nothing about double-tap in the other browsers. The double-tap-inhibiting of the is irritating, because seems good practice.

    
    

提交回复
热议问题