i am using a timer on my php page but when some refresh the page the timer start from begin. i want to disable f5 or reload option on my php page.
Thanks in advance
i am using a timer on my php page but when some refresh the page the timer start from begin. i want to disable f5 or reload option on my php page.
Thanks in advance
Share Improve this question edited Sep 10, 2013 at 18:43 Ankit Agrawal asked Mar 31, 2013 at 19:03 Ankit AgrawalAnkit Agrawal 6,1246 gold badges27 silver badges49 bronze badges 5 |3 Answers
Reset to default 9I test it and it works.
function disable_f5(e)
{
if ((e.which || e.keyCode) == 116)
{
e.preventDefault();
}
}
$(document).ready(function(){
$(document).bind("keydown", disable_f5);
});
Can't be done – that behaviour is controlled by the end user, and rightly so!
The nearest thing you can do is to display a warning when the window is closed or refreshed, which the user can either decide to heed your warning and stick with the current page, or ignore your request and close/refresh anyway.
See here: Alert when browser window closed accidentally
It is impossible to disable such browser functionality. Would you like it if a page disabled your F5 key? I doubt it. If you are trying to implement some kind of security here, I suggest looking at proper server-side verification approaches.
onbeforeunload
and restore it inonload
. – Maerlyn Commented Mar 31, 2013 at 19:17