简体   繁体   English

jQuery:如何知道页面是否已刷新

[英]jQuery: How to know if a page has been refreshed

I would like to know if it is possible to check if a certain page has been refreshed after clicking browser reload button or F5 and create a specific function. 我想知道是否可以在单击浏览器重新加载按钮或F5并创建特定功能后检查特定页面是否已刷新。

For example: 例如:

if(page has been refreshed) {
 code
} else {
 other code
}

when a page is refreshed, the page and all js variables will be restored to its original state. 刷新页面时,页面和所有js变量将恢复到其原始状态。 You might be able to do it if you set a flag in the browser's cookies or localstorage, so when the user refresh the page, you can check if the flag was set. 如果您在浏览器的cookie或本地存储中设置了标记,则可能能够执行此操作,因此,当用户刷新页面时,可以检查标记是否已设置。

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

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