简体   繁体   中英

How to Detect Page Refresh in IE, caused by refresh button and Context Menu ?

I need to control the page behavior when user click on IE refresh button or from right click -> refresh. Is it possible to detect these action , if yes How?

您可以在重新加载之前执行操作-OnBeforeUnload()。

 window.onbeforeunload = function (e) {
e = e || window.event;
// For IE and Firefox prior to version 4
if (e) {
    e.returnValue = 'Are you sure? You will lose unsaved changes.';
}
// For Safari
return 'Are you sure? You will lose unsaved changes.';
};

here is the snippet which checks the reload functionality on a page.

Regards

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