IOS版的InApp浏览器phoneGap不会从本地服务器加载页面



这是我正在使用的代码:

<html>
<head>
<script>
function open_win()
{
window.open(encodeURI("<inserturlhere>"))
}
</script>
</head>
<body>
<input type="button" value="Open Window" onclick="open_win()">
</body>
</html>

它适用于谷歌、apache等其他网站。

我已授予对config.xml文件中所有域的访问权限。

我认为您在窗口末尾缺少分号()。如果它是错误编写的,请尝试以下代码

<html>
  <head>
    <script>
      var ref=null;
      function iabLoadStart(event) {
         console.log(event.type + ' - ' + event.url);
      }
      function iabLoadStop(event) {
         console.log(event.type + ' - ' + event.url);
      }
      function iabClose(event) {
         console.log(event.type);
         ref.removeEventListener('loadstart', iabLoadStart);
         ref.removeEventListener('loadstop', iabLoadStop);
         ref.removeEventListener('exit', iabClose);
      }
      function open_win() {
         ref=window.open(encodeURI("<inserturlhere>"),'_blank', 'location=no');
         ref.addEventListener('loadstart', iabLoadStart);
         ref.addEventListener('loadstop', iabLoadStop);
         ref.addEventListener('exit', iabClose);
      }
    </script>
  </head>
  <body>
    <input type="button" value="Open Window" onclick="open_win()">
  </body>
</html> 

您指的是从文件系统提供的本地文件吗?Ie.file://而不是http://?在这种情况下,我认为这是当前Phonegap版本的一个错误。

我一直在使用这个方法(打开一个inappbrowser实例):

// Image zoom
$('#container').on('tap', '#content.cmscontent img', function() {
    var browser = window.open((navigator.userAgent.indexOf('Android') != -1 ? 'file:///android_asset/www/' : '') + encodeURI($(this).attr('src')), '_blank', 'location=no,toolbar=yes,enableViewportScale=yes,transitionstyle=crossdissolve');
});

请参阅我在url之前添加了(navigator.userAgent.indexOf('Android') != -1 ? 'file:///android_asset/www/' : '')作为前缀。现在,它可以检测你的应用程序何时在Android上,并在其前面添加本地URL。

最新更新