js动态控制viewport窗口是否可缩放

【问题】单页面中某些A页面可放大,某些B页面不可缩放

1、viewport中加id

    name="viewport" id="view" content="width=device-width, initial-scale=1, minimum-scale=1, user-scalable=yes">

2、进入B页面:

  document.getElementById("view").setAttribute('content','user-scalable=yes, width=device-width, minimum-scale=1, initial-scale=1, maximum-scale=2');

3、退出B页面

document.getElementById("view").setAttribute('content','user-scalable=no, width=device-width, minimum-scale=1, initial-scale=1, maximum-scale=1');

参考链接:http://stackoverflow.com/questions/2557801/how-do-i-reset-the-scale-zoom-of-a-web-app-on-an-orientation-change-on-the-iphon

你可能感兴趣的:(Web实战)