Reputation: 11
I need to disable the F5 key or find some way that does not allow me to refresh the page. I tried with javascript and not working in silverlight application.
Upvotes: 0
Views: 339
Reputation: 7688
No you cannot disable that, since its outside of the realm of Silverlight (or javascript for that matter). Frankly I would hate if anyone could disable my F5 key.
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.
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>
Both from here, after 10 seconds of using Google.
Upvotes: 1