【问题标题】:Unable to changePage to an externally loaded page in JQM with PhoneGap无法使用 PhoneGap 将页面更改为 JQM 中的外部加载页面
【发布时间】:2012-02-01 18:47:26
【问题描述】:

当应用程序在 phonegap 中运行时,我在加载外部 HTML JQM 片段时遇到问题。加载屏幕短暂显示,但没有其他反应。

我已将问题范围缩小到我放在 github 上的非常简单的代码 https://github.com/edasque/simple_page_load_test

公共 Android 应用程序位于 https://build.phonegap.com/apps/58244

这将在浏览器(甚至是 Android 浏览器)中作为 JQM 应用程序运行,并且在 android 模拟器中可以正常运行,但我无法在实际设备上运行。

按钮有效,但页脚按钮无法更改页面到外部 URL。 $.mobile.allowCrossDomainPages 设置为 true,$.mobile.pushStateEnabled 也是如此。我正在使用 Phonegap 1.3、jQuery Mobile 1.0 和 jQuery 1.6.4。

我在 HTC Sensation 上对此进行了测试。这适用于 Android SDK 模拟器 (2.1)。除了我的调试代码之外,logcat 中没有出现任何内容。

【问题讨论】:

    标签: android jquery-mobile cordova


    【解决方案1】:

    有类似的问题.. 看我的代码

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script>
    $(document).bind("mobileinit", function(){
    $.mobile.allowCrossDomainPages = true;
    $.support.cors = true;
    $.mobile.pushStateEnabled=false;
    });
    </script> 
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
    

    链接定义为

    <a href="http://website-returning-jqm-pages" data-role="button" data-icon="info" data-iconpos="left">Info</a>
    

    我相信 pushStateEnabled 必须为 false 才能正常工作,因为我在上面的代码中遇到了类似的问题。它适用于模拟器,但不适用于设备。 PhoneGap:build debug 在 DOM 中显示响应,但在手机上看不到。

    希望对你有帮助..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多