[转] A JS shielded keyboard code, classic!

xiaoxiao2021-03-06  36

From:

http://community.9cbs.net/expert/topic/3766/3766060.xml?temp=.3094904

Please write a JavaScript code to prevent the user from refresh the web page after submitting the form (for example, press F5 or press the refresh button on the IE) to re-submit the form. The page submission is submitted to this page on this page. Do you help me?

The following code just implements the right mouse button, Ctrl N, Shift F10, F5 refresh, and check.

Function KeyDown () {

/ / Shield mouse button, Ctrl N, Shift F10, F5 refresh, check

// Alert ("ASCII code is:" Event.KeyCode);

IF ((Window.Event.altKey) &&

((Window.Event.Keycode == 37) || // Shield Alt arrow keys ←

(Window.Event.Keycode == 39))) {// Shield Alt Direction Key →

Alert ("Do not allow you to use the Alt direction button to advance or retreat!");

Event.ReturnValue = false;

}

IF ((Event.Keycode == 8) || // Mask Deng Delete button

(Event.keycode == 116) || // Shield F5 Refresh Keys

(Event.keycode == 112) || // Shield F1 Refresh Keys

(Event.ctrlKey && event.keycode == 82)) {// ctrl r

Event.Keycode = 0;

Event.ReturnValue = false;

}

IF ((Event.ctrlKey) && (event.keycode == 78)) // Shield Ctrl N

Event.ReturnValue = false;

IF ((Event.ShiftKey) && (event.keycode == 121)) // Shield Shift F10

Event.ReturnValue = false;

IF (window.event.srcelement.tagname == "a" && window.event.shiftkey)

Window.Event.ReturnValue = false; // Shield Shift razor left button new open page

IF (WINDOW.Event.AltKey && (Window.Event.KeyCode == 115)) {// Shield Alt F4

Window.ShowModelessDialog ("About: Blank", "DialogWidth: 1PX; Dialogheight: 1px");

Return false;}

}

转载请注明原文地址:https://www.9cbs.com/read-61960.html

New Post(0)