dubbelj
dubbelj

Reputation: 1160

Disabling mobile Safari's focus event (zoom)

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

Upvotes: 9

Views: 11675

Answers (4)

Denis Staci
Denis Staci

Reputation: 61

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">

Upvotes: 0

Chugworth
Chugworth

Reputation: 490

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

Upvotes: 0

Rowan
Rowan

Reputation: 626

I think you would be better to set the viewport:

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

See this thread

Upvotes: 2

zachleat
zachleat

Reputation: 3327

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.

Upvotes: 13

Related Questions