javascript - href 不工作,如何重定向到 PhoneGap 中的特定页面?

标签 javascript android html cordova jquery-mobile

在 Html5 中,我按以下方式转到特定页面:

window.location.href = "http://localhost:XXXX/MyPageName.html";

点击按钮的 href 不起作用!!我不知道为什么,这是我解决这个问题的唯一方法。

当我使用 PhoneGap 运行 html5 应用程序时,链接不起作用(显然,因为应用程序没有本地主机)

我该如何解决这个问题?

最佳答案

首先,您的链接可能无效,因为 cordova/phonegap 默认阻止所有外部 URL。要解决此问题,请阅读 my answer here .

其次,Phonegap 不打开网络服务器,所以 http://localhost是不正确的。当你想要一个内部链接时,使用类似 <a href="/mydir/mypage.html">linkText</a> 的东西.

关于javascript - href 不工作,如何重定向到 PhoneGap 中的特定页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13683992/

相关文章:

javascript - jQuery:如何匹配 ids 的最后部分

html - 了解相对和绝对定位 : how to align an internal div to the bottom of the container

javascript - 如何检查字符串是否包含 JavaScript 中的子字符串?

javascript - TextInputMask 仅适用于正数

android - 无法从R8配置中删除 “-ignorewarnings”(Android Proguard问题)

android - 从多个库创建AAR文件

javascript - 通过缩放调整自定义图像标记的大小 - Google Maps API v3

javascript - IndexedDB 存储 250kB/s 流数据的性能问题

android - 使用 OpenCV 进行模板匹配

html - CSS 网格 : on small devices the card does not display inside grid box