Disable zoom on input focus in Android webpage

后端 未结 30 1284
日久生厌
日久生厌 2020-12-02 05:17

Here\'s the dilema, I have a webpage (only for android devices) and in that page I have an input box (a text box specifically) and when it gets focus the browser zooms in. I

30条回答
  •  半阙折子戏
    2020-12-02 05:56

    Perhaps you could avoid zoom, by resetting the zoom scale to 1.0? On my Android (HTC Wildfire S), I'm able to reset zoom to 1.0 like so:

    $('meta[name=viewport]').attr('content',
             'initial-scale=1.0, maximum-scale=0.05');
    

    but this moves the viewport to 0, 0 (the upper left corner of the page). So I $().scrollLeft(...) and .scrollTop(...) back to the form again.

    (initial-scale=1.0, maximum-scale=0.05 is my initial value of the viewport meta.)

    (The reason I do this is not to prevent Android from zooming, but rather to reset the zoom to a known scale, because of other Android bugs that otherwise corrupt screen.width and other related values.)

提交回复
热议问题