在phonegap中调用页面

时间:2014-04-13 13:57:59

标签: javascript cordova

我有一个问题:我已经创建了这个页面来加载,我希望在加载页面game.html结束时加载开始游戏,但是我不能这样做,我立即上传游戏而不是上传页面。

<html>

<style type="text/css">
#body {
    position:absolute;
    width:100%;
    height:100%;
    background: black;
    top:0;
    margin-left:-8;
    padding:0;
    overflow: hidden;    
}

#loading {
    background: transparent;
    /* border: none !important;*/
    position:relative;
    top:30px;
    outline: none;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font: bold 20px Arial, Helvetica, sans-serif;
    color: black;
    padding: 10px 20px;
    border: solid 1px #0076a3;
    background: url("img/riempimento.jpg");
    -moz-border-radius: 8px;
    -webkit-border-radius: 8px;
    border-radius: 8px;
    -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
</style>
<div id="body">
<br></br><br></br><br></br><br></br>
<div id="loading">Caricamento...
</div>

<script>
    function finish() {
        document.getElementById("body").style.visibility = "hidden";
        document.getElementById("loading").style.visibility = "hidden";
    }

window.location="game.html";
</script>
<body onload="finish();"></body>
</html>

1 个答案:

答案 0 :(得分:0)

我认为您的问题是在加载脚本期间更改页面(window.location) - 而不是在onLoad函数中。尝试重写为这样的东西:

<script>
    function finish() {
        document.getElementById("body").style.visibility = "hidden";
        document.getElementById("loading").style.visibility = "hidden";
        window.location = "game.html";
    }
</script>

更新。 Html代码:

<html>
<head>
    <style type="text/css">
        ... styles stay there
    </style>
    <script>
        function finish() {
            document.getElementById("body").style.visibility = "hidden";
            document.getElementById("loading").style.visibility = "hidden";
            window.location = "game.html";
        }
    </script>
</head>
<body onload="finish();">
    <div id="body">
        <br></br><br></br><br></br><br></br>
        <div id="loading">Caricamento...</div>
    </div>
</body>
</html>