简体   繁体   English

如何在应用Silverlight中禁用键F5

[英]How to disable key F5 in aplication Silverlight

I need to disable the F5 key or find some way that does not allow me to refresh the page. 我需要禁用F5键或找到某种不允许我刷新页面的方法。 I tried with javascript and not working in silverlight application. 我尝试使用JavaScript,但无法在Silverlight应用程序中工作。

No you cannot disable that, since its outside of the realm of Silverlight (or javascript for that matter). 不,您不能禁用它,因为它不在Silverlight(或与此相关的javascript)领域之内。 Frankly I would hate if anyone could disable my F5 key. 坦白说,我讨厌如果有人可以禁用我的F5键。

Your solution would be to store the state of the app in the isolated storage, so if the app refreshes, you restore the state from where it left off. 您的解决方案是将应用程序的状态存储在隔离的存储中,因此,如果应用程序刷新,则可以从中断状态恢复状态。

But there is hope: 但是有希望:

One option is to hook into the window object 'onbeforeunload' event and prompt the user to confirm the refresh/exit intent. 一种选择是挂接到窗口对象“ onbeforeunload”事件中,并提示用户确认刷新/退出意图。

Here is a simple example that could be defined in your HTML markup or even emitted from the SL app (if it has DOM access): 这是一个简单的示例,可以在您的HTML标记中定义,甚至可以从SL应用程序发出(如果它具有DOM访问权限):

<script type="text/javascript">
   window.onbeforeunload = function() {
   return "Leaving or refreshing this page can result in data loss.";
}
</script>

Both from here , after 10 seconds of using Google. 使用Google 10秒后, 两者均从此处开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM