简体   繁体   中英

How to prevent zooming and moving page on mobile browsers?

As in title, im looking for working scrypt to block zooming and if possible block moving page, it can be JQuery, JavaScript, HTML or even PHP.

I tried <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0>" But didnt work. Looking forward for helpful ideas.

试试这个:

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

Your above code should work. This usually works for me.

<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

Here's some documentation

This meta-tags work fine for me.

<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />

Answers to this question discribes how to turn off moving page in safary: Mobile Safari: Disable scrolling pages "out of screen"

The problem is your user-scalable=0 attribute.

It should be user-scalable=no .

user-scalable - Determines whether or not the user can zoom in and out—whether or not the user can change the scale of the viewport. Set to yes to allow scaling and no to disallow scaling. The default is yes . Setting user-scalable to no also prevents a webpage from scrolling when entering text in an input field. Available in iOS 1.0 and later.

( Apple Safari Dev )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM