【问题标题】:Phonegap error using only phonegap Not using Phonegap + nativePhonegap 错误仅使用 phonegap 不使用 Phonegap + native
【发布时间】:2012-11-16 07:22:45
【问题描述】:

我已经问了很多天了,我想现在已经排好队了,所以我再次发布这个问题,请告诉我任何人都可以帮助我

ERROR    the connection to the server was unsuccessful. (file ///android_asset/www/index.html) pure    phonegap app

代码如下:

<html>
<head>
<link rel="stylesheet" href="jquery-mobile/jquery.mobile.css">
<link rel="stylesheet" href="jquery-mobile/jqm-docs.css">
<script src="jquery-mobile/jquery.js"></script>
<script>
$(document).bind("mobileinit", function(){
    $.mobile.loadingMessageTextVisible = true;
});
</script>
<script src="jquery-mobile/jquery_mobile_old.js"></script>
<script>
    $(document).on("click", ".show-page-loading-msg", function() {
        var $this = $( this ),
            theme = $this.jqmData("theme") || $.mobile.loadingMessageTheme,
            msgText = $this.jqmData("msgtext") || $.mobile.loadingMessage,
            textonly = !!$this.jqmData("textonly");
        $.mobile.showPageLoadingMsg(theme, msgText, textonly);
    })
    .on("click", ".hide-page-loading-msg", function() {
        $.mobile.hidePageLoadingMsg();
    });
</script>

</head>
<body>
<div data-role="header"><h1>My App</h1></div>

<a href="http://xyz.php" style="text-decoration:none">
<button class="show-page-loading-msg">xyz</button>
</a> <a href="http://xyz.php" style="text-decoration:none">
<button class="show-page-loading-msg">xyz</button>
</a> <a href="http://xyz.php" style="text-decoration:none">
<button class="show-page-loading-msg">xyz</button>
</a> <a href="http://xyz.php" style="text-decoration:none">
<button class="show-page-loading-msg">xyz</button>
</a> <a href="http://xyz.php" style="text-decoration:none">
<button class="show-page-loading-msg">xyz</button>
</a> <a href="http://xyz.php" style="text-decoration:none">
<button class="show-page-loading-msg">xyz</button>
</a> <a href="http://xyz.php" style="text-decoration:none">
<button class="show-page-loading-msg">xyz</button>
</a> <a href="#" style="text-decoration:none">
<button class="show-page-loading-msg">Outstanding Analysis For Creditors</button>
</a> 

但它在浏览器中运行良好。

问题是当我尝试在手机中打开它时出现错误。我正在使用 Dreamweaver CS6 并在 https://build.phonegap.com/ 中构建它

【问题讨论】:

    标签: android cordova jquery-mobile mobile phonegap-plugins


    【解决方案1】:

    在使用 build.phonegap.com 时,您是否有权访问包含加载页面的活动的 .java 文件。如果是,则最有可能检查路径,网页的 url 不正确。

    html 文件的名称也是正确的,如错误消息中所示。

    您是否查看过page.. 中的文档。请记住,文件名是 index.html 而不是 index.htm 或其他任何东西。

    更新: 我试图将 phonegap.js 的代码放入一个单独的文件中,但没有包含对 phonegap.js 的引用,应用程序不起作用。所以看起来,在 index.html 文件中包含对 phonegap.js 的引用很重要。

    <html>
    <head>
    <meta name="viewport" content="user-scalable=no, initial-scale=3, maximum-scale=3, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=high-dpi" />
            <link rel="stylesheet" type="text/css" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.css" />
    
          <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
          <script type="text/javascript" charset="utf-8" src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.js"></script>
          <script src="phonegap.js"></script>
    <script>
    $(document).bind("mobileinit", function(){
        $.mobile.loadingMessageTextVisible = true;
    });
    </script>
    <script src="jquery-mobile/jquery_mobile_old.js"></script>
    <script>
        $(document).on("click", ".show-page-loading-msg", function() {
            var $this = $( this ),
                theme = $this.jqmData("theme") || $.mobile.loadingMessageTheme,
                msgText = $this.jqmData("msgtext") || $.mobile.loadingMessage,
                textonly = !!$this.jqmData("textonly");
            $.mobile.showPageLoadingMsg(theme, msgText, textonly);
        })
        .on("click", ".hide-page-loading-msg", function() {
            $.mobile.hidePageLoadingMsg();
        });
    </script>
    
    </head>
    <body>
    <div data-role="header"><h1>My App</h1></div>
    
    <a href="http://xyz.php" style="text-decoration:none">
    <button class="show-page-loading-msg">xyz</button>
    </a> <a href="http://xyz.php" style="text-decoration:none">
    <button class="show-page-loading-msg">xyz</button>
    </a> <a href="http://xyz.php" style="text-decoration:none">
    <button class="show-page-loading-msg">xyz</button>
    </a> <a href="http://xyz.php" style="text-decoration:none">
    <button class="show-page-loading-msg">xyz</button>
    </a> <a href="http://xyz.php" style="text-decoration:none">
    <button class="show-page-loading-msg">xyz</button>
    </a> <a href="http://xyz.php" style="text-decoration:none">
    <button class="show-page-loading-msg">xyz</button>
    </a> <a href="http://xyz.php" style="text-decoration:none">
    <button class="show-page-loading-msg">xyz</button>
    </a> <a href="#" style="text-decoration:none">
    <button class="show-page-loading-msg">Outstanding Analysis For Creditors</button>
    </a> 
    

    【讨论】:

    • 这是我的 index.html 页面,我没有使用任何 .java 文件。
    • 我以前从未使用过 build.phonegap.com。但出于好奇,我看了看。使用该应用程序时似乎唯一的问题是,如果通过 zip 文件或使用存储库上传的代码是文件夹结构不正确。
    • 文件夹结构没问题,如果把&lt;body&gt;Hello&lt;/body&gt;放在这个页面中并删除所有的js文件,页面就可以正常加载到手机中了。
    • 我应该早点意识到这一点,但是您的页面缺少对&lt;script src="phonegap.js"&gt;&lt;/script&gt; 的引用。如果您查看我在回答中提供的链接,则有一个部分指出您需要拥有参考.. link
    • 这是文件&lt;script src="jquery-mobile/jquery_mobile_old.js"&gt;&lt;/script&gt;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-19
    • 2016-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多