简体   繁体   English

通过单击后退按钮重新加载上一页

[英]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.

相关问题 是否可以在单击浏览器后退按钮时重新加载同一页面? - is it possible to reload the same page on clicking browsers back button? 通过在Firefox中单击“后退”按钮来重新加载访问时的页面 - Reload the page when visited by clicking Back button in Firefox 使用“后退”按钮时重新加载(刷新)上一页 - Reload (fresh-load) previous page when back button is used 缩放网页,然后单击“后退”按钮更改上一页的背景大小 - Zooming webpage then clicking back button changes the background size on the previous page 不允许将CSS携带到上一页(单击浏览器后退按钮后) - Not allowing CSS to be carried to previous page (after clicking browser back button) 返回上一页,无需重新加载 - Back to previous page without reload 单击浏览器的“后退”按钮时,返回上一页的上一个位置 - Go Back to the Previous Location on Previous Page when Clicking Browser Back Button 单击浏览器后退按钮时,将用户带回上一页滚动到的位置 - Take User Back to Where They Scrolled to on previous page when clicking Browser Back Button 如何通过在javascript中单击浏览器的后退按钮将页面恢复到之前的状态 - How to take back a page to its previous state by clicking the back button of the browser in javascript 单击浏览器后退按钮时如何转到当前页面的上一页 - How to go previous page of current page , while clicking browser back button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM