最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jquery mobile changePage() not working correctly - Stack Overflow

programmeradmin2浏览0评论

I am creating a webapp using phonegap and jquerymobile. When i am using changePage to go to other page then it is not working.Here is my code

<!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>

But when i use

window.location.href = 'file:///android_asset/www/account_page.html';

Then it is working...Why is it so?

I am creating a webapp using phonegap and jquerymobile. When i am using changePage to go to other page then it is not working.Here is my code

<!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>

But when i use

window.location.href = 'file:///android_asset/www/account_page.html';

Then it is working...Why is it so?

Share Improve this question asked Feb 20, 2012 at 12:51 coderslaycoderslay 14.4k32 gold badges81 silver badges122 bronze badges 1
  • It works, may be try $.mobile.changePage("account_page.html") only... – viv Commented Feb 8, 2014 at 7:04
Add a ment  | 

1 Answer 1

Reset to default 9

$.mobile.changePage doesnt load another html into view. it scans the html in the html whose link u gave, gets the first jqm 'page' on it and adds that into the dom(not the entire html)
If this is not what you intended to do and wanted to load the full account_page.html into the dom then u'll have to use either

window.location.href or navigator.app.loadUrl
发布评论

评论列表(0)

  1. 暂无评论