Disable auto zoom/field zoom on input tags on my Mobile Site - WITHOUT disabling all zoom capabilities

后端 未结 6 1131
迷失自我
迷失自我 2020-12-24 11:54

I have spent all day looking for a solution, and this site keeps coming up, SO why not ask you guys.

I an building our companies mobile website and we want to disabl

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-24 12:24

    It took me a while to find it but here's the best code that I found......http://nerd.vasilis.nl/prevent-ios-from-zooming-onfocus/

    var $viewportMeta = $('meta[name="viewport"]');
    $('input, select, textarea').bind('focus blur', function(event) {
    $viewportMeta.attr('content', 'width=device-width,initial-scale=1,maximum-scale=' +        (event.type == 'blur' ? 10 : 1));
    });
    

提交回复
热议问题