jquery mobile changePage()无法正常工作 [英] jquery mobile changePage() not working correctly

查看:141
本文介绍了jquery mobile changePage()无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用phonegap和jquerymobile创建了一个webapp。当我使用changePage去其他页面,那么它不工作。这是我的代码

 <!DOCTYPE HTML& 
< html>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
< meta name =viewportcontent =width = device-width; user-scalable = no/>
< script type =text / javascriptcharset =utf-8src =phonegap-1.4.1.js>< / script>
< script type =text / javascriptsrc =jquery-1.7.1.min.js>< / script>
< link rel =stylesheethref =jquery.mobile-1.0.1.min.css/>
< script type =text / javascriptsrc =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.JPGalt =login_screenwidth =320onclick =clickEvent()/>
< / div>
< / body>
< / html>

但是当我使用

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

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


< div。移动。交换页面没有加载另一个html到视图。它扫描html中的链接u给出的html,获取第一个jqm'页',并将其添加到dom(而不是整个html)
如果这不是你打算做的,想加载full account_page.html into the dom then u'll have to use either

  window.location.href或navigator.app.loadUrl 


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?

解决方案

$.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

这篇关于jquery mobile changePage()无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆