How to hide overlay pressing Back button

℡╲_俬逩灬. 提交于 2020-01-03 05:22:31

问题


Firstly: I ma very new in jQuery and web front-end.

Problem: I have a test site

Steps to see the problem:

  1. Click on [UploadTest]
  2. Click on any pic in gallery to see an overlay
  3. Click on browser's Back button

Now I see main page with the overlay. Question is how to hide overlay when I leave the gallery page by Back button?

Sometime othe overlay is hidden but when I go on gallery page again it is visible.

How to hide it automatically?

Thanks.

UPDATE: Sorry, I can not post sources because I do not know where is problem. Please if you have a minute look inside sources in browser.


回答1:


$(document).ready(function () {
    if (window.history && window.history.pushState) {
        $(window).on('popstate', function () {
            $("#galleryOverlay").css('display', 'none')
        });
    }
});


来源:https://stackoverflow.com/questions/23760625/how-to-hide-overlay-pressing-back-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!