Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4875
  • Last Modified:

How can I capture in javascript ctrl-R or F5?

Anuone has any code available of capturing the How can I capture in javascript ctrl-R or F5 key.

Thanks
Nesifa
0
nesifa
Asked:
nesifa
1 Solution
 
jitgangulyCommented:
116 is the number. but it does not work with ctrl+R
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function getKey(keyStroke) {
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;

if (eventChooser==116)
alert("Please don't press f5");

}
document.onkeydown = getKey;
// -->
</SCRIPT>
</HEAD>
<BODY>
Press a key to see the ascii code.
</BODY>
</HTML>
0
 
Chandramouli kArchitectCommented:
HI GANGULY
IT's working even for CTRL+R

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function getKey(keyStroke) {
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;

if (eventChooser==116)
     alert("Please don't press f5");
if (event.ctrlKey)
     {
     if(eventChooser==82) alert("CTRL+R");
     }

}
document.onkeydown = getKey;
// -->
</SCRIPT>
</HEAD>
<BODY>
Press a key to see the ascii code.
</BODY>
</HTML>

KCM
0
 
tejaspuraniCommented:
still not disabling the F5 Function. can u do that?

TP
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Chandramouli kArchitectCommented:
U cannot disable (built-in features) F1 - help, F3 - find, F4 - drop down address list - and so on.

KCM


0
 
viapekCommented:
If you want to stop the refresh, add return false. This should stop it.

Ova
0
 
tejaspuraniCommented:
Viapek,

No it's not !!!!

TP
0
 
nesifaAuthor Commented:
You are the first and everybody else played with your original code. You deserve it.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now