2

嘿,我已经创建了一个在 android 上运行良好的 android/iphone 应用程序,但由于某种原因,它只是显示启动屏幕/加载动画,而不是过去。

这是屏幕的样子:

在此处输入图像描述

在我的 config.xml 文件中,我有:

<!--App settings -->
    <preference name="phonegap-version"                                     value="2.3.0" />
    <preference name="orientation"                                          value="portrait" />
    <preference name="fullscreen"                                           value="true" />
    <preference name="exit-on-suspend"                                      value="true" />
    <preference name="auto-hide-splash-screen"                              value="false" />
    <preference name="splash-screen-duration"                               value="10000" />
    <preference name="webviewbounce"                                        value="true" />

在我的javascript中,我有:

    //Wait for device
    function onDeviceReady() {
        navigator.splashscreen.hide();
    }

    document.addEventListener("deviceready", onDeviceReady, false);

但是,我将此代码用于 index.html 文件:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=310;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title></title>
</head>

<body>
<script>
    window.location='https://fb.zzzzzzz.com/xxxxxx/index.php';
</script>
</body>
</html>

我缺少什么设置?可能是因为我在 .html 之后调用了 .php 页面吗?

4

1 回答 1

0

在触发和处理设备就绪事件后,它对我有用。

JavaScript

var app = {
    // Application Constructor
    initialize: function() {
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // 'load', 'deviceready', 'offline', and 'online'.
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    //
    // The scope of 'this' is the event. In order to call the 'receivedEvent'
    // function, we must explicity call 'app.receivedEvent(...);'
    onDeviceReady: function() {
        app.receivedEvent('deviceready');
    },
    // Update DOM on a Received Event
    receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event: ' + id);
        window.location='https://fb.zzzzzzz.com/xxxxxx/index.php';
    }
};

HTML

<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
    app.initialize();
</script>
于 2013-05-20T19:02:06.357 回答