Disabling mobile Safari's focus event (zoom)

后端 未结 3 1855
清酒与你
清酒与你 2020-12-16 03:29

When clicking an input field on an iOS device, it will zoom in on that element. Can i disable this focus event?

相关标签:
3条回答
  • 2020-12-16 04:00

    I think you would be better to set the viewport:

    <meta name="viewport" content="width=device-width, user-scalable=no" />
    

    See this thread

    0 讨论(0)
  • 2020-12-16 04:05
     document.getElementById("idOfInputField").onfocus = function(){return false;}
    
    0 讨论(0)
  • 2020-12-16 04:12

    I put up this gist which solves the problem. https://gist.github.com/2008932

    The accepted solution is not correct, as it will cancel focus altogether, which prevents data entry.

    0 讨论(0)
提交回复
热议问题