javascript - H5页面用js控制缩放问题
黄舟
黄舟 2017-04-11 10:11:01
0
1
283

var phoneWidth = parseInt(window.screen.width);

     var phoneScale = phoneWidth/640;
     var ua = navigator.userAgent;
     if (/Android (\d+\.\d+)/.test(ua)){
           var version = parseFloat(RegExp.$1);
           if(version>2.3){
                    document.write('<meta name="viewport" content="width=640, minimum-scale = '+phoneScale+', maximum-scale = '+phoneScale+', target-densitydpi=device-dpi">');
           }else{
                    document.write('<meta name="viewport" content="width=640, target-densitydpi=device-dpi">');
           }
           } else {
                   document.write('<meta name="viewport" content="width=640, user-scalable=no, target-densitydpi=device-dpi">');
          }

我看网上都有用这段js代码来控制页面百分百缩放,但是我在用的过程中发现页面切换不是百分百,就是说在切换的过程中,页面会先缩小再放大,求问大神们有解决的办法吗?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
伊谢尔伦
<meta name="viewport" content="width=device-width,target-densitydpi=device-dpi,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">

在头部meta加上这个

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!