jquery mobile changePage()无法正常工作

Cod*_*LaY 2 javascript jquery-mobile cordova

我正在使用phonegap和jquerymobile创建一个webapp.当我使用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>
Run Code Online (Sandbox Code Playgroud)

但是当我使用时

window.location.href = 'file:///android_asset/www/account_page.html';
Run Code Online (Sandbox Code Playgroud)

然后它正在工作......为什么会这样?

gho*_*der 9

$ .mobile.changePage不会将另一个html加载到视图中.它扫描你的链接你给的html中的html,获取它上面的第一个jqm'页面'并将其添加到dom(而不是整个html)
如果这不是你想要做的并想加载完整的account_page. html进入dom然后你将不得不使用

window.location.href or navigator.app.loadUrl
Run Code Online (Sandbox Code Playgroud)