开发者

Disabling mobile Safari's focus event (zoom)

开发者 https://www.devze.com 2023-02-11 02:21 出处:网络
开发者_如何学PythonWhen clicking an input field on an iOS device, it will zoom in on that element. Can i disable this focus event?I put up this gist which solves the problem.
开发者_如何学Python

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


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.


I think you would be better to set the viewport:

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

See this thread


 document.getElementById("idOfInputField").onfocus = function(){return false;}


Best solution to disable auto zoom in mobile devices on touch event

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号