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?
Asked
Active
Viewed 928 times
0
-
You can detect someone *leaving* a page (even if they are simply refreshing it in their browser); is that sufficient? – Adrian Wragg May 19 '15 at 11:46
-
No that will not perform the task, as user can leave the page due to post back also, so only in this specific scenario I want to refresh the page with some url changes. In HTML 5 we can change the url firectly, but as we still supporting IE8, so before refreshing I need to put Hash value in URL. Please suggest. – Dreamweaver May 20 '15 at 07:09
-
In which case, what you're after isn't possible. Note that both the answers you've had so far don't meet this requirement. – Adrian Wragg May 20 '15 at 10:30
-
yes, please guide how to do that ? – Dreamweaver May 21 '15 at 10:20
-
will have a look...n let u know.. thanks :) – Dreamweaver May 21 '15 at 12:07
-
Is the link works? ? – Dreamweaver May 22 '15 at 11:09
-
1http://stackoverflow.com/questions/18457797/how-to-know-whether-refresh-button-or-browser-back-button-is-clicked-in-firefox is an approach I can follow.. :) – Dreamweaver May 22 '15 at 11:54
2 Answers
0
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

imran qasim
- 1,050
- 13
- 18
-
*loose* - not firmly or tightly fixed. *lose* - to cease to have. – Adrian Wragg May 20 '15 at 10:32
-
-
You've used the word "loose" in your prompts; the word you're after is "lose". It's a very common error. – Adrian Wragg May 20 '15 at 12:08