Silverlight: How do I disable to browser's refresh button?
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>
精彩评论