开发者

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

开发者 https://www.devze.com 2023-02-04 21:39 出处:网络
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.

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?


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>
0

精彩评论

暂无评论...
验证码 换一张
取 消