Windows Phone 8的phonegap中没有调用onload方法

时间:2013-12-02 01:59:07

标签: cordova windows-phone-8

我正在使用phonegap为html5创建应用程序,它从www文件夹加载html,js,css文件。附件是我的index.html。问题是initappcache方法,我试图调用onload没有被调用。请帮助我。

<!DOCTYPE HTML>
<html manifest="spaiphone/test.manifest" >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
        <meta name="format-detection" content="telephone=no" />
        <meta name="format-detection" content="address=no" />      
        <script type="text/javascript"> 
            if(document.getElementById && document.createElement){
                document.write("<style>html {display: none;}</style><script>if( self == top ){document.documentElement.style.display = 'block';} else {top.location = self.location;}</sc"+"ript>");
            }else{
                if (top != self){
                    top.location = self.location;
                }
            }
        </script>
        <style>
            @-webkit-keyframes FadeIn{ 
                0%{ 
                    opacity:0;
                } 
                100%{ 
                    opacity:1;
                }
            }
            .splashscreen {
                position: fixed !important;
                position: absolute;
                top: 0px;
                right: 0px;
                left: 0px;
                bottom: 0px;
                background-color: #000000;
            }
            .splashscreen2{
                text-align: center;
            }
            .splashscreen-image {
                -webkit-animation-name: FadeIn;
                -webkit-animation-timing-function: ease-in;
                -webkit-animation-duration: 1.5s;
                width:100%;
                height:100%;
            }        
        </style>
        <link rel="stylesheet" type="text/css" href="spaiphone/jslib/tparty/cal/container.css" />
        <link rel="stylesheet" type="text/css" href="spaiphone/jslib/tparty/cal/calendar.css" />
    </head>
    <body>
        <input type="hidden" name="_konyAppProperties" value='' >
        <input type="hidden" name="_reqHeaders" value='{"Host":"localhost%3A8888","Connection":"keep-alive","Accept":"text%2Fhtml%2Capplication%2Fxhtml%2Bxml%2Capplication%2Fxml%3Bq%3D0.9%2C*%2F*%3Bq%3D0.8","User-Agent":"Mozilla%2F5.0+%28BB10%3B+Touch%29+AppleWebKit%2F537.1%2B+%28KHTML%2C+like+Gecko%29+Version%2F10.0.0.1337+Mobile+Safari%2F537.1%2B","Accept-Encoding":"gzip%2Cdeflate%2Csdch","Accept-Language":"en-US%2Cen%3Bq%3D0.8","Cookie":"JSESSIONID%3D1g8sg1u4glv3e","Cache-Control":"no-cache","Pragma":"no-cache"}' >

        <div id="splashScreen_main" class="splashscreen">
            <div id="splashScreen" class="splashscreen2">
                <img id="splashScreenImage" class="splashscreen-image" src="spaiphone/images/mvsplashscreenandroid.png" >
            </div>
        </div>

        <!-- <noscript style="position:absolute;background:white;">To use this site, first enable your browser;kqt;s JavaScript support and then refresh this page.</noscript> -->

        <style>
            #__JSDisabledErrorMsg{display:none;}
        </style>

        <noscript>
            <style>
                #__JSDisabledErrorMsg{display:block;}
            </style>
        </noscript>

        <div id="__JSDisabledErrorMsg" style="position:absolute;background:white;">To use this site, first enable your browser;kqt;s JavaScript support and then refresh this page.</div>

        <script type="text/javascript" >

            // for css file : begin
            var orientation = window.orientation;
            var category = window.innerWidth;
            if(orientation) {
                category = Math.min(window.innerWidth, window.innerHeight);
            }
            if(orientation && parseInt(category, 10) > 250) {
                category = 360
            } else if( orientation || parseInt(category, 10) < 340) {
                category = 320;
            } else {
                category = 360;
            }
            if(window.devicePixelRatio > 2)
                category = 440;
            alert("Category: "+category);
            var filename = "spaiphone/konyspabb" + category + ".css?ver=6.0.1";
            // for css file : end

            // for splash image : begin
            var splImgNode=document.getElementById("splashScreenImage");
            if(splImgNode){
                splImgNode.src="spaiphone/images/mvsplashscreenandroid.png";
                splImgNode.style.display="block";
            }
            // for splash image : end

            var filename = "spaiphone/konyspaiphone.css";
            var link = document.createElement("link");
            link.setAttribute("rel", "stylesheet");
            link.setAttribute("type", "text/css");
            link.setAttribute("href", filename);
            document.getElementsByTagName("head")[0].appendChild(link);          

            IndexJL = 0;
            function initappcache(){
                $KG["version"] = "6.0.1";
                alert("222222")
                test.appinit.initappcache();
            }
            var head = document.getElementsByTagName('head')[0]; 
            var script = document.createElement('script');  

            script.src = "spaiphone/jslib/testinit.js";
            alert("567567")
            script.onload = initappcache;
            head.appendChild(script);               
        </script>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

调用函数时需要添加()。像:

script.onload = "initappcache();"