search

Home  >  Q&A  >  body text

javascript - Browser rollback, how to ensure that js operations on dom are saved

1. There are multiple external links written on the homepage;
2. When you enter the homepage, a pop-up window will be displayed. When it is clicked to close, use the js click event to set the display of the pop-up window to none and hide the pop-up window;
3. Click to enter other link pages, and then go back through the browser's back button or Android phone WeChat. It will return to the homepage, but the pop-up window will pop up again. Is there any solution? After going back, you don’t want the pop-up window to be displayed, and it will be displayed as the state before the jump

仅有的幸福仅有的幸福2709 days ago711

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-06-26 10:56:39

    Set a cookie, record the status, and enter the page to determine whether there is a cookie. If there is a cookie, there will be no pop-up window. If not, there will be a pop-up window.

    reply
    0
  • 扔个三星炸死你

    扔个三星炸死你2017-06-26 10:56:39

    As mentioned above, using cookies, jquery’s cookie is particularly simple. If you don't consider supporting IE browser, you might as well use h5's new features localstorage or sessionstorage.

    reply
    0
  • 阿神

    阿神2017-06-26 10:56:39

    Cookie, localstorage; there is also an event popstate that may be used in conjunction with history.pushState
    cookie should be able to achieve the effect.

    reply
    0
  • Cancelreply