简体   繁体   中英

jQuery run only once, even on back button press

I have a page that loads an runs some jQuery. If I refresh the page, it's fine because it only runs the one time on a specific action. However, if the jQuery runs, then I go forward a page, and then back a page. The jQuery will run again because it is still loaded from last time. Is there something I can do that make jQuery only run once, even on a back button press?

您可以使用通过cookie / sessionStorage存储的状态,并基于cookie来确定是否再次运行它

Do you use jQuery Ajax? give it property -> cache: false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM