[英]Reload the previous page by clicking the back button
My main page look like this: 我的主页看起来像这样:
<body>
<div id="MainPage" data-role="page">
<script>
$("#MainPage").live("pageinit", function () { ... });
</script>
...//I have a map and when I walk to the next page I delete the map.
</div>
</body>
My next page look like this: 我的下一页如下所示:
<body>
<div id="NextPage" data-role="page">
<script>
$("#NextPage").live("pageinit", function () {... });
</script>
<a data-res="btnBack" data-role="button" data-theme="b" href="MainPage.html"
data-icon="back" data-iconpos="left" onclick="document.MainPage.reload(true);">
</a>
...//I have a map and when I walk to the Main page I delete the map.
</div>
</body>
Because I delete the maps I have to reload the main page and it does not work that way, the main page is not recognized as a page and therefore has no reload function. 因为我删除了地图,所以我必须重新加载主页,但这种方式无法正常工作,因此无法将主页识别为页面,因此没有重新加载功能。
Can anyone help? 有人可以帮忙吗?
Try to save the web address of the main page when you go from main page to next page. 从主页转到下一页时,请尝试保存主页的网址。
for example : you use a link or button to traverse from one page to other use this code to save the url of the current page and then send it to other page using querystring or something else. 例如:您使用链接或按钮从一个页面遍历到另一个页面,使用此代码保存当前页面的url,然后使用querystring或其他方式将其发送到另一页面。
$(document).ready(function(){
var url =$(location).attr("href");
});
variable 'url' contains the url of main page , now reload function to reload it. 变量'url'包含主页的url,现在使用reload函数来重新加载它。 as: 如:
$(document).ready(function(){
window.reload(url);
})
To jump to any other page use this code: 要跳至任何其他页面,请使用以下代码:
$.mobile.changePage("#page", {transition: "none", reloadPage : false});
Set a transition effect if you want one, and set reloadPage true if you want to reload that page. 如果需要,设置过渡效果,如果要重新加载该页面,则将reloadPage设置为true。
Use this code to reload current page: 使用以下代码重新加载当前页面:
function refreshPage() {
$.mobile.changePage(
window.location.href,
{
allowSamePageTransition : true,
transition : 'none',
showLoadMsg : false,
reloadPage : true
}
);
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.