0

how capturing the event to refresh the screen?

asked 2010-02-15 10:40:15 +0800

softteam gravatar image softteam
130 1 8

hello all,

I need to detect when the user presses the button to refresh the screen (F5) or disable this feature, anyone can help me?

Thanks

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2010-02-15 14:16:43 +0800

kesavkolla gravatar image kesavkolla
180 3

You can't restrict the user to stop refreshing the page. The browser is user's application and he has all the rights to do what ever he wants to do with his application he can close it open it navigate where ever he wants. If you are developing web application you shouldn't put these restrictions in your web pages. If you need such an ability you should consider developing desktop applications either in Win32 or .NET etc..

The other alternative is Adobe AIR or Site specific browsers (SSB) using that you can deploy your web applications on to users desktops. These give you an ability to control user actions.

link publish delete flag offensive edit

answered 2010-02-16 01:28:12 +0800

satshcool gravatar image satshcool
39

updated 2010-02-16 01:29:52 +0800

you can do this with JavaScript.
to hide toolbar, menu ... etc., open your web application with this JS function that you can set according to your needs :

window.open("yourZKWebPage","windowName","width=200,height=100,toolbar=no,location=no,directories=no ,status=yes,menubar=no,scrollbars=no,resizable=yes");

And here, is an old code to intercept keyboard input, you can also customize it according to your needs :

function keydown() {
  if ((window.event.ctrlKey) || (window.event.shiftKey) || (window.event.keyCode==18) || ((window.event.keyCode>=112) && (window.event.keyCode<=123))) {
   if (window.confirm("Shortcuts are not allowed ! \nDo you want to exit this great site ?" ))
    top.close();
   else {
    setTimeout("form.focus();",30);
    window.event.returnValue = false;  
   }
   }
  }
document.onkeydown= keydown //All Keys are checked 

link publish delete flag offensive edit

answered 2010-02-17 08:56:51 +0800

softteam gravatar image softteam
130 1 8

Thank you very much :)

link publish delete flag offensive edit

answered 2010-03-09 00:18:34 +0800

Thiru gravatar image Thiru
147 5

Dear all,

How to use above javascript in zk ,

Please help me
Thanks in advance

Regards
Thiru

link publish delete flag offensive edit

answered 2010-03-09 00:37:28 +0800

Thiru gravatar image Thiru
147 5

Hi All,

i'm able to call javascript,

It is throwing an alert, but not restricting the refresh fucntion, is there any code to deactivated refresh action,

Regards,
Thiru

link publish delete flag offensive edit

answered 2010-03-09 21:50:14 +0800

PeterKuo gravatar image PeterKuo
481 2

I tried following code in zk5, it works.
You have to use jquery to cross browser.


<zk>
<window title="forum 11347">
Hello, World!
<label id="aa" value="dd"/>
<button label="change" onClick='aa.value="cc"'/>
</window>
<script><![CDATA[
(function($) {
$.fn.extend({
disableF5Key: function() {
$(window.document).keydown(disableF5InnerFunc);
}
});

function disableF5InnerFunc(event) {
var e;
if ($.browser.msie) { e = window.event; } else { e = event; }
if (e.keyCode == 116) { e.keyCode = 0; return false; }
if (e.altKey && (e.keyCode == 37 || e.keyCode == 39)) { return false; }
};
})(jQuery);
$.fn.disableF5Key();
]]>
</script>

</zk>

link publish delete flag offensive edit

answered 2010-03-09 23:56:03 +0800

Thiru gravatar image Thiru
147 5

Thank you PeterKuo,

the above code is working fine in zk5, disabled F5 key press functionality.

how to avoid refreshing page while clicking browser refresh icon
and is there any similar code for zk3.5

link publish delete flag offensive edit

answered 2010-03-10 00:28:20 +0800

PeterKuo gravatar image PeterKuo
481 2

@Thiru,
for ZK3.5, you have to include jquery lib manually.
About browser refresh icon, you may google, see if there is sample javascript code for it.
After all, the above sample just use <script> to execute javascript in browser.
The rest is how to implement it in javascript.

link publish delete flag offensive edit

answered 2012-10-02 08:38:36 +0800

riczun gravatar image riczun
36 2
www.riczun.nl

Thanks for the great post it really helped me. Works in all browsers IE, firefox, opera and tested it in ZK 6!

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2010-02-15 10:40:15 +0800

Seen: 1,601 times

Last updated: Oct 02 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More