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

时间:2013-08-01 21:18:19

标签: cordova inappbrowser

以下是我正在使用的代码:

<html>
<head>
<script>
function open_win()
{
window.open(encodeURI("<inserturlhere>"))
}
</script>
</head>
<body>

<input type="button" value="Open Window" onclick="open_win()">
</body>
</html>

适用于google,apache等其他网站。

我已经访问了config.xml文件中的所有域。

2 个答案:

答案 0 :(得分:0)

我认为你在窗口末尾缺少分号(; )。如果错误地写了,请尝试下面的代码

<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> 

答案 1 :(得分:0)

您的意思是从文件系统提供的本地文件吗? 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');
});

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