我的主页是这样的:
<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>
因为我删除了 map ,所以我必须重新加载主页,但这样不行,主页不被识别为页面,因此没有重新加载功能。
有人能帮忙吗?
最佳答案
从主页面转到下一个页面时尽量保存主页面的网址。
例如: 您使用链接或按钮从一个页面遍历到另一个页面使用此代码保存当前页面的 url,然后使用查询字符串或其他方式将其发送到其他页面。
$(document).ready(function(){
var url =$(location).attr("href");
});
变量'url'包含主页的url,现在重新加载函数重新加载它。作为:
$(document).ready(function(){
window.reload(url);
})
关于javascript - 单击后退按钮重新加载上一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13582507/