In Asp.net, right-click shielding, CTRL + N, Shift + F10, F11, F5 refresh, and backspace keys are blocked.

Source: Internet
Author: User
Right-click the block, CTRL + N, Shift + F10, F11, F5 refresh, and return key. The original text is as follows:
// Block the function document by right-clicking, CTRL + N, Shift + F10, F11, F5 refresh, and backspace. oncontextmenu () {event. returnvalue = false;} // right-click the screen and select function window. onhelp () {return false} // block the F1 help function document. onkeydown () {If (window. event. altkey) & (window. event. keycode = 37) | // mask Alt + direction key trim (window. event. keycode = 39) // block Alt + direction keys → {// alert ("You are not allowed to use Alt + direction keys to move forward or backward the webpage! "); Event. returnvalue = false;}/* Note: this does not really block Alt + direction keys, because when the Alt + direction keys pop up the warning box, hold down the Alt key and drop the warning box with the mouse, this blocking method becomes invalid. In the future, if any expert has a method to block the Alt key, please let us know. */If (event. keycode = 8) | // specifies the event that is used to block the unsigned deletion key. keycode = 116) | // block the F5 refresh key (event. ctrlkey & event. keycode = 82) {// Ctrl + R event. keycode = 0; event. returnvalue = false;} If (event. keycode = 122) {event. keycode = 0; event. returnvalue = false;} // block F11 if (event. ctrlkey & event. keycode = 78) event. returnvalue = false; // block Ctrl + n if (event. shiftkey & event. keycode = 121) event. returnvalue = false; // block SHIFT + F10 if (window. event. srcelement. tagname = "A" & window. event. shiftkey) window. event. returnvalue = false; // block shift with the left mouse button to open a new page if (window. event. altkey) & (window. event. keycode = 115) // block Alt + F4 {// window. showmodelessdialog ("about: blank", "", "dialogwidth: 1px; dialogheight: 1px"); Return false ;}}

Now, you need to block these buttons on the project. After the backspace key is blocked, it cannot be used in the text box. This brings great inconvenience to users. Change to the following Code To solve this problem.
// Block the function document by right-clicking, CTRL + N, Shift + F10, F11, F5 refresh, and backspace. oncontextmenu () {event. returnvalue = false;} // right-click the screen and select function window. onhelp () {return false} // block the F1 help function document. onkeydown () {If (window. event. altkey) & (window. event. keycode = 37) | // mask Alt + direction key trim (window. event. keycode = 39) // mask Alt + direction keys → {event. returnvalue = false;}/* Note: this does not really block Alt + direction keys, because when the Alt + direction keys pop up the warning box, hold down the Alt key and drop the warning box with the mouse, this The blocking method becomes invalid. In the future, if any expert has a method to block the Alt key, please let us know. */If (event. keycode = 116) | // block the F5 refresh key (event. ctrlkey & event. keycode = 82) {// Ctrl + R event. keycode = 0; event. returnvalue = false;} If (event. keycode = 122) {event. keycode = 0; event. returnvalue = false;} // block F11 if (event. ctrlkey & event. keycode = 78) event. returnvalue = false; // block Ctrl + n if (event. shiftkey & event. keycode = 121) event. returnvalue = false; // block SHIFT + F10 if (window. event. srcelement. tagna Me = "A" & window. event. shiftkey) window. event. returnvalue = false; // block shift with the left mouse button to open a new page if (window. event. altkey) & (window. event. keycode = 115) // block the control of ALT + F4 {return false;} // backspace buttons. VaR EV = Window. event; var OBJ = ev.tar GET | eV. srcelement; var T = obj. type | obj. getattribute ('type'); var vreadonly = obj. getattribute ('readonly'); var venabled = obj. getattribute ('enabled'); vreadonly = (vreadonly = NULL )? False: vreadonly; venabled = (venabled = NULL )? True: venabled; // when you press the backspace key, if the event source type is password or single-line or multi-line text, // and the readonly attribute is true or the enabled attribute is false, vaR flag1 = (ev. keycode = 8 & (t = "password" | T = "text" | T = "textarea ") & (vreadonly = true | venabled! = True ))? True: false; // when you press the backspace key, if the event source type is non-password or single-line or multi-line text, the Return key fails to be var flag2 = (ev. keycode = 8 & T! = "Password" & T! = "Text" & T! = "Textarea ")? True: false; If (flag2) {return false;} If (flag1) {return false ;}}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.