简体   繁体   English

如果用户单击“返回”,如何在上一页中隐藏引导程序模式?

[英]How to hide a bootstrap modal on the previous page if user comes in clicking BACK?

I have a website that queries a large database. 我有一个查询大型数据库的网站。 It takes a while (3-10 sec) to generate a page. 生成页面需要一段时间(3-10秒)。 This is no problem for users, but I want to show a friendly message instead of the user just sitting in front of a page that is not changing. 对于用户而言,这没有问题,但是我想显示一个友好的消息,而不是让用户只是坐在没有变化的页面前。 So what I did is I show a bootstrap modal saying "Please wait, we're loading your page" when a user clicks any particular link. 所以我要做的是当用户单击任何特定链接时显示一个引导模式,说“请稍等,我们正在加载您的页面”。 That works well. 那很好。 The modal is shown on the page, and when the server has generated the new page, it will open and the modal clearly disappears. 该模式显示在页面上,并且服务器生成新页面后,它将打开,并且模式明显消失。

The problem is when the user navigates to another link (again seeing the modal on the page), and then moves back. 问题是当用户导航到另一个链接(再次在页面上看到模式)时,然后移回。 The previous modal is now shown. 现在显示以前的模态。 See overview below: 请参阅下面的概述:

  • Page A: loads instantly 网页A:立即加载
  • Clicks on link to page B. Modal shown: "Please wait for B". 单击链接到页面B。显示的模式为:“请稍候B”。
  • Page B shown. 显示了页面B。
  • Clicks on link to page C. Modal shown: "Please wait for C". 单击链接到C页。显示的模式:“请稍候C”。
  • Page C shown. 页面C已显示。
  • User clicks BACK button to page B. The last 'mode' of Page B shows the "Please wait for C" message in a modal, because that is where it ended. 用户单击“返回”按钮到页面B。页面B的最后一个“模式”以模态形式显示“请稍候C”消息,因为这是结束的地方。 The content has clearly already loaded (from browser cache). 内容显然已经加载(从浏览器缓存中)。

How to fix this? 如何解决这个问题?

Set this header 设置此标题

header("Cache-Control: private, must-revalidate,
    max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0"
);

Also see: How to Defeat the Browser Back Button Cache 另请参阅: 如何击败浏览器后退按钮缓存

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过以引导方式单击图像将值传递回主页 - How to pass a value by clicking on an image in bootstrap modal back to the main page 仅当用户来自该页面时,如何在提交表单后将 CodeIgniter 中的 URL 重定向回上一页? - How to redirect URL in CodeIgniter after form submission back to the previous page only when the user comes from that page? 在使用jQuery单击后退按钮后,如何检查页面是否出现? - How to check if a page comes after clicking the back button using jQuery? 我在引导程序模式后面单击什么 - What am I clicking on bootstrap modal back 单击浏览器后退按钮时,将用户带回上一页滚动到的位置 - Take User Back to Where They Scrolled to on previous page when clicking Browser Back Button 单击按钮时如何从页面(Bootstrap 4)中隐藏或删除搜索表单? - How to hide or remove the search form from the page (Bootstrap 4) on clicking a button? 通过单击后退按钮重新加载上一页 - Reload the previous page by clicking the back button 如何通过单击第一页中的按钮激活 Bootstrap 4 模态,将您重定向到激活模态的第二页? - How to activate Bootstrap 4 modal by clicking a button in the first page, that redirects you to a second page with modal activated? 如何在第二次访问WordPress页面时隐藏引导程序模式 - how to hide bootstrap modal on second visit of a wordpress page 如何在我的 web 页面中隐藏或显示引导模式? - How can I hide or show a bootstrap modal in my web page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM