Reputation: 1057
How to get event of page refresh. i want to detect that user has refreshed page
Upvotes: 2
Views: 7641
Reputation: 1506
The event you're looking for is beforeunload, you can stop a page refresh like this:
$(window).bind('beforeunload', function(){
return '';
});
Upvotes: 0
Reputation: 6023
On $(document).load()
Upvotes: 2
Reputation: 10806
not sure how to do it in Jquery
window.onbeforeunload = function (e) {
var e = e || window.event;
// For IE and Firefox
if (e) {
e.returnValue = 'Any string';
}
// For Safari
return 'Any string';
};
https://developer.mozilla.org/en/DOM/window.onbeforeunload
Upvotes: 2