Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable zoom on input focus in Android webpage

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 don't want it to zoom in - sounds easy, right?

Here's where it gets fun: I have to be able to zoom in general so don't say

<meta name='viewport' content='user-scalable=0'> 

That won't work for me.

Also, the input box doesn't receive click events. It appears when another button is clicked a gets focus programmatically.

Here's what I've tried and they've failed so far:

jQuery('head meta[name=viewport]').remove(); jQuery('head').prepend('<meta name="viewport" content="width=720px;intial-scale=1.0;maximum-scale=1.0;user-scalable=no" />'); jQuery("#locationLock input").focus(); jQuery('head meta[name=viewport]').remove(); jQuery('head').prepend('<meta name="viewport" content="width=720px;intial-scale=1.0;maximum-scale=1.0;user-scalable=yes" />'); 

This also failed:

<input type='text' onfocus="return false"> 

And this:

jQuery("#locationLock input").focus(function(e){e.preventDefault();}); 

Any ideas?

like image 266
Coomie Avatar asked Aug 16 '11 03:08

Coomie


People also ask

How do I stop web pages from zooming in?

By default, Chrome sets the zoom level to 100%. To manually adjust the settings, use the Ctrl key and “+” or “-” combos to increase or decrease the page magnification. If you are using a mouse, you can hold down the keyboard Ctrl key and use the mouse wheel to zoom in or out.

How do I stop zoom on input focus on IOS devices?

If you enlarge the field by increasing all dimensions by 16 / 12 = 133.33%, then reduce using scale() by 12 / 16 = 75%, the input field will have the correct visual size (and font size), and there will be no zoom on focus.

How do I disable zoom in react native Webview?

How to disable zoom on react-native web-view ,is there a property like hasZoom={false} (just an example) that can be included in the below web-view tag that can disable zooming.


1 Answers

The following worked for me (Android Galaxy S2):

<meta name="viewport" content="width=device-width, height=device-height,  initial-scale=1.0, user-scalable=no;user-scalable=0;"/> 
like image 95
rebpp Avatar answered Sep 25 '22 16:09

rebpp