【问题标题】:Phonegap build 3.7, HTML, window.open redirect on iphonePhonegap build 3.7,HTML,iphone上的window.open重定向
【发布时间】:2015-06-22 00:47:10
【问题描述】:

我正在尝试在 iPhone 上构建的 Phonegap(版本 3.7)中从打开的 index.html 到另一个 html(main2b.html)进行简单的重定向,但没有成功。它在 Android 上运行良好。这是对我需要做的事情的简化测试。

如果我以 window.location.href='http://www.google.com' 为例,它不起作用。 (是的,我在我的 config.xml 中将其列入白名单) 如果我 window.location.href='main2b.html' 它只是旋转并且也不起作用。

出于测试目的,main2b.html 只是 div 中的一个简单的“hello”。 我尝试了 main2b.html 的各种路径选项,但没有成功,所以我觉得这不是路径问题。两个 html 文件位于同一位置。

这是代码示例。将不胜感激任何想法。这似乎是一件很简单的事情,无法弄清楚什么是错的。

一旦这个简单的测试工作,我需要做这样的事情,我将检测我的应用程序是否“离线”,因此转到不同的 html 文件。这就是为什么我在任何 jquery/mobile 初始化内容之前执行此操作的原因,如果我检测到我“在线”,这些内容稍后会出现。

index.html 代码:

<!DOCTYPE html> 
<html> 
     <head>             
        <title>The Conspiracy Show</title> 
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"/>
       
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1 user-scalable=no, " />

        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black" />

        <!-- Phonegap build stuff required ----------- -->
        <script src="cordova.js"></script>      
        <!------------------------>
      
        <script>              
            function onLoad(){
                alert('here at onLoad');
                document.addEventListener("deviceReady", deviceReady, false);
              }
            
            function deviceReady() {
                alert('here at deviceReady')
                window.location.href = "main2b.html";
            }             
        </script>  
       
    </head> 
    <body  onload="onLoad()"> 
        
    </body>
</html>

main2b.html 是这样的

<!DOCTYPE html> 
<html> 
        
    <head> 
      <title>The Conspiracy Show App</title>  
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"/>
        <meta name="keywords" content="conspiracy Richard Syrett talk show Coasttocoastam paranormal callIn"/> 

        <!-- Required Stuff for PhoneGap prevent page flickering in iOS----------- -->
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black" />

        <!-- Phonegap build stuff required ----------- -->
    <script src="cordova.js"></script>      
     
    </head>

    <body style="background:#2D5873;" >
        <div align="center" style="margin:0px; padding:0px;">
            Hello
        </div>

    </body>
</html>

【问题讨论】:

    标签: iphone html cordova redirect


    【解决方案1】:

    我发现了自己的问题。显然,在 iPhone 中,如果您没有专门关闭启动画面(只能在 deviceReady 之后完成),任何重定向都将不起作用。在android上,闪屏关闭可以立即完成。总之,问题解决了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-05
      • 1970-01-01
      • 1970-01-01
      • 2013-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多