[英]is it possible to reload the same page on clicking browsers back button?
[英]Reload the previous page by clicking the back button
我的主页看起来像这样:
<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>
我的下一页如下所示:
<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>
因为我删除了地图,所以我必须重新加载主页,但这种方式无法正常工作,因此无法将主页识别为页面,因此没有重新加载功能。
有人可以帮忙吗?
从主页转到下一页时,请尝试保存主页的网址。
例如:您使用链接或按钮从一个页面遍历到另一个页面,使用此代码保存当前页面的url,然后使用querystring或其他方式将其发送到另一页面。
$(document).ready(function(){
var url =$(location).attr("href");
});
变量'url'包含主页的url,现在使用reload函数来重新加载它。 如:
$(document).ready(function(){
window.reload(url);
})
要跳至任何其他页面,请使用以下代码:
$.mobile.changePage("#page", {transition: "none", reloadPage : false});
如果需要,设置过渡效果,如果要重新加载该页面,则将reloadPage设置为true。
使用以下代码重新加载当前页面:
function refreshPage() {
$.mobile.changePage(
window.location.href,
{
allowSamePageTransition : true,
transition : 'none',
showLoadMsg : false,
reloadPage : true
}
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.