[英]Disable reload and f5 on my php page
i am using a timer on my php page but when some refresh the page the timer start from begin. 我在我的php页面上使用计时器但是当一些刷新页面时,计时器从开始开始。 i want to disable f5 or reload option on my php page.
我想在我的php页面上禁用f5或重新加载选项。
Thanks in advance 提前致谢
I 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);
});
It is impossible to disable such browser functionality. 禁用此类浏览器功能是不可能的。 Would you like it if a page disabled your F5 key?
如果页面禁用了你的F5键,你会喜欢它吗? I doubt it.
我对此表示怀疑。 If you are trying to implement some kind of security here, I suggest looking at proper server-side verification approaches.
如果您尝试在此处实现某种安全性,我建议您查看正确的服务器端验证方法。
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 请参阅此处: 浏览器窗口意外关闭时发出警报
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.