仅使用phonegap的Phonegap错误不使用Phonegap + native

时间:2012-11-16 07:22:45

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

我前几天问过这个问题我觉得现在已经排队了所以我再次发布这个请告诉我任何人都可以帮助我

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/

中构建它

1 个答案:

答案 0 :(得分:0)

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

也是正确的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> 
相关问题