Dynamic viewport with js Cordova or Phonegap Android KitKat 4.4

我只是一个虾纸丫 提交于 2019-12-13 02:20:17

问题


I'm using the following code to resize/scaling my app to the screen size of the any device (iOS, Android):

<head>
<meta charset="utf-8"> 
<title>App Title</title>
<meta id="Viewport" name="viewport">     
<script src="plugins/jquery-1.10.2.min.js"></script>   
<link rel="stylesheet" href="css/main.css" />
<script src="plugins/main.js"></script>
<script src="cordova.js"></script>
<script type="text/javascript">
    $(function(){
    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
      var ww = ( $(window).width() < window.screen.width ) ? $(window).width() : window.screen.width; 
      var mw = 1080;
      var ratio =  ww / mw;
      if( ww < mw){
       $('#Viewport').attr('content', 'initial-scale=' + ratio + ', maximum-scale=' + ratio + ', minimum-scale=' + ratio + ', user-scalable=yes, width=' + ww);
      }else{
       $('#Viewport').attr('content', 'initial-scale=' + ratio + ', maximum-scale=' + ratio + ', minimum-scale=' + ratio + ', user-scalable=yes, width=' + ww);
      }
    }
    });                                             
</script></head> 

and it works perfectl on iOS and Android to Api lvl 18, stop working on lvl 19 KitKat 4.4.2 I read that: PhoneGap uses Android WebView before KitKat (4.4) but how to make this code work for which I have given ? looks as if they do not execute js

or any suggestions other solution ???

Thx for any suggestions

UPDATE 30.04.2014

I also setup manualy viewport without js and on Android 4.3 works perfect but on 4.4.2 not working at all - I use Cordova 3.4.0 in Eclipse

来源:https://stackoverflow.com/questions/23371386/dynamic-viewport-with-js-cordova-or-phonegap-android-kitkat-4-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!