Silverlight: How do I disable to browser's refresh button?

房东的猫 提交于 2020-01-23 07:51:35

问题


I'm working on a Silverlight application (i.e. no HTML content at all) and one of biggest complaints is that if the user accidentally hits F5 the application restarts.

So is there any way I can disable the Refresh button in the browser? Or at least handle F5?


回答1:


Here are couple of options

http://forums.silverlight.net/forums/p/105879/243232.aspx

From link:

One option is to hook into the window object 'onbeforeunload' event and prompt the user to confirm the refresh/exit intent. 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):

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


来源:https://stackoverflow.com/questions/4673715/silverlight-how-do-i-disable-to-browsers-refresh-button

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!