PDA

View Full Version : Disable F5 Error Help


Darksbane
08-14-2002, 02:01 PM
here is my code:

if(event && event.keyCode == 116){
// Capture and remap F5
keyString = String.fromCharCode(event.keyCode).toLowerCase();
alert(keyString);
alert (event.keyCode)
window.event.keyCode = 505;
}

if(event && event.keyCode == 505){
// New action for F5
alert('F5 key was pressed');
return false;
// Must return false or the browser will refresh anyway
}

My problem is that this also disables the 't' key. I am using IE 5.0 and when I view the keycode and the string entered when these two keys are pressed they are the same (they both return a keycode of 116 and a string 't'). I am doing this to try to disallow the refreshing of specific page (as when it is refreshed it screws up other parts of my code)

Any help would be appreciated.

Darksbane

beetle
08-14-2002, 03:04 PM
The KeyCode for 't' is 84. I don't understand the problem you're having...

Besides, how does this stop anyone from using their toolbar's refresh button, or using View >> Refresh from the menu bar?

Darksbane
08-14-2002, 03:08 PM
The keycode for 'T' is 84 the keycode for 't' and F5 is 116. As far as the other forms of refreshing goes the application I am developing is in a cromeless window, so no refresh button or tool bar. I have also disabled Alt + r and right clicking as well. I am just running into a problem with lowercase t and F5 as they seem to use the same keycode. The above script disables both keys since they are both returning 116 as the code.

beetle
08-14-2002, 03:12 PM
Strange, coz at this (http://msdn.microsoft.com/workshop/samples/author/dhtml/refs/onkeydown.htm) page I always get 84. I mean, the event shouldn't care about the case of the letter, becuase they are both the same key on the keyboard...

Darksbane
08-14-2002, 03:35 PM
OK thanks for showing me that page. Apparently it was interfering with the script which disables right clicking. Somehow the Right clicking script was reassigning the value for t before it checked to see what the keycode was.

Thanks
Darksbane

beetle
08-14-2002, 04:07 PM
Also, what about Shift+F10?