When clicking an input field on an iOS device, it will zoom in on that element. Can i disable this focus event?
Asked
Active
Viewed 1.1k times
4 Answers
13
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.

zachleat
- 3,318
- 1
- 23
- 20
-
Excellent! Can't believe everyone is still advising viewport hacks when this seems to solve this issue quite elegantly. Thanks – thatguy Mar 07 '13 at 07:46
-
3For the record, this is a viewport hack—it’s just dynamic in JavaScript. :) – zachleat Mar 07 '13 at 16:29
-
If you are using mobile boilerplate (http://html5boilerplate.com/mobile/) with helper.js you can call MBP.preventZoom(), its does pretty much the same work – Davor Jun 05 '13 at 23:04
-
1Perfect, this is exactly what I was looking for. All others were giving foul behavior or messing with the viewPort to the point where responsiveness would be overwritten. Thanks Zach! – Dylan Aug 14 '14 at 15:06
2
I think you would be better to set the viewport:
<meta name="viewport" content="width=device-width, user-scalable=no" />
-
I disagree. With @zachleat's solution it is not needed to completely disable zooming. Disabling zooming alltogether in most cases is a bad idea: you're disabling a standard interaction. – Fer Mar 17 '14 at 21:27
-
Not only is this user hostile it also doesn’t work (thankfully) in iOS10+. – Robin Whittleton Sep 20 '17 at 11:46
0
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">

Denis Staci
- 61
- 3