Solved

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

Posted on 2002-04-02
7
4,491 Views
Last Modified: 2007-12-19
Anuone has any code available of capturing the How can I capture in javascript ctrl-R or F5 key.

Thanks
Nesifa
0
Comment
Question by:nesifa
7 Comments
 
LVL 20

Accepted Solution

by:
jitganguly earned 30 total points
ID: 6913532
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
 
LVL 5

Expert Comment

by:kcm76
ID: 6913590
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
 
LVL 3

Expert Comment

by:tejaspurani
ID: 6914075
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!

 
LVL 5

Expert Comment

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

KCM


0
 

Expert Comment

by:viapek
ID: 6914866
If you want to stop the refresh, add return false. This should stop it.

Ova
0
 
LVL 3

Expert Comment

by:tejaspurani
ID: 6915958
Viapek,

No it's not !!!!

TP
0
 

Author Comment

by:nesifa
ID: 6921759
You are the first and everybody else played with your original code. You deserve it.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question