问题
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