检测到F5被按下并刷新
我有一个网络表单,我想检测 F5 按钮是否被按下或者页面是否被刷新。 我知道回发,但这不是我要找的。 我有一个 gridview,当单击按钮并为 gridview 设置参数值时,它会在模式弹出窗口中加载。 当点击刷新时,如果先前单击了模式弹出按钮,则模式弹出窗口在刷新后立即可见。 我想检测页面是否刷新以防止这种情况。 有任何想法吗? 我想尝试覆盖,但我不太确定如何使用它。 我尝试了 Control.ModifierKeys 但无法访问 ModifierKeys。
I have a webform and i want to detect if F5 button was pressed or if the page was refreshed. I know about postback but it is not what i'm looking for. I have a gridview that loads in a modal popup when a button is clicked and a parameter's value is set for the gridview. When refresh is hit and if the modal popup button was previously clicked the modal popup is visible right after refresh. I want to detect if the page is refreshed to prevent this. any ideas? I thought to try Override but I'm not exactly sure how to use it. I tried Control.ModifierKeys but I don't have access to ModifierKeys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
按 F5 或物理单击浏览器刷新的行为与导航离开页面类似。 这是在事件 window.onunload 中捕获的。 尝试下面的 snippet 示例:
这将捕获刷新并允许您执行某些操作或提示用户。
Pressing F5 or physically clicking the browser refresh behaves similarly to navigating away from the page. This is captured in the event window.onunload. Try the snippet example below:
This will capture the refresh and allow you to do something or prompt the user.
请记住,热键是在浏览器的客户端处理的。 实现这一点的最简单方法是通过 javascript。
查看以下链接:
http://snippets.dzone.com/posts/show/3552< /a>
Reemember that hotkeys are processed in the client side in the browser. The easiest way to implement this is through javascript.
Look at the following link:
http://snippets.dzone.com/posts/show/3552