我正在使用 phonegap 和 jquerymobile 创建一个网络应用程序。当我使用 changePage 转到其他页面时,它不起作用。这是我的代码
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width; user-scalable=no" />
<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<link rel="stylesheet" href="jquery.mobile-1.0.1.min.css" />
<script type="text/javascript" src="jquery.mobile-1.0.1.min.js"></script>
</head>
<script type="text/javascript">
function clickEvent()
{
$.mobile.changePage("account_page.html", null, true, true);
}
</script>
<body>
<div style="top: 0; left: 0; position: absolute; z-index: 1;">
<img src="images/login_screen.JPG" alt="login_screen" width="320" onclick="clickEvent()"/>
</div>
</body>
</html>
但是当我使用
window.location.href = 'file:///android_asset/www/account_page.html';
那么它正在工作...为什么会这样?
最佳答案
$.mobile.changePage 不会将另一个 html 加载到 View 中。它扫描您提供链接的 html 中的 html,获取其上的第一个 jqm“页面”并将其添加到 dom(而不是整个 html)
如果这不是您打算做的并且想要加载将完整的 account_page.html 放入 dom 然后你将不得不使用
window.location.href or navigator.app.loadUrl
关于javascript - jquery mobile changePage() 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9361422/