JS backspace key: JS shielding function Class (shielding F5, backspace keys, space bar ...)

Source: Internet
Author: User
Tags delete key key return window

1. Shielding function class
1.1 Screen Keyboard all keys
<script language= "JavaScript" >
<!--
function Document.onkeydown () {
Event.keycode = 0;
Event.returnvalue = false;
}
-->
</script>
1.2 Screen right mouse button
Add Oncontextmenu=self.event.returnvalue=false to the body tag.
Or
<script language= "JavaScript" >
<!--
function Document.oncontextmenu ()
{
return false;
}
-->
</script>
function Nocontextmenu ()
{
if (document.all) {
Event.cancelbubble=true;
Event.returnvalue=false;
return false;
}
}
Or
<body oncontextmenu= "Nocontextmenu ()" >
<script language= "JavaScript" >
<!--
function Rclick ()
{
if (document.all) {
if (Event.button = = 2) {
Event.returnvalue=false;
}
}
}
-->
</script>
1.3 Mask CTRL + N, Shift+f10, F5 refresh, backspace key
<script language= "JavaScript" >
<!--
Screen the right mouse button, CTRL + N, Shift+f10, F5 refresh, backspace key
function Window.onhelp () {return false}//Shield F1 Help
function KeyDown () {
if ((Window.event.altkey) &&
((window.event.keycode==37)//shielding ALT + Direction key ←
(window.event.keycode==39))) {//Shielding ALT + Direction key →
Alert ("You are not allowed to use ALT + arrow keys forward or back page!") ");
Event.returnvalue=false;
}
* Note: This is not really shielding ALT + arrow keys,
Because ALT + ARROW keys pop-up warning box, hold down the ALT key,
With the mouse point off the warning box, this shielding method is invalid. Later if
There is a master who has really shielded the Alt key method, please inform. */
if (Event.keycode = &&
(Event.srcelement.type!= "text" &&
Event.srcelement.type!= "textarea" &&
Event.srcelement.type!= "password")//Screen BACKSPACE delete key
(Event.keycode ==116)//Screen F5 refresh key
(Event.ctrlkey && event.keycode==82)) {//ctrl + R
event.keycode=0;
Event.returnvalue=false;
}
if ((Event.ctrlkey) && (event.keycode==78))//Mask CTRL + N this article link http://www.cxybl.com/html/wyzz/JavaScript_Ajax/ 20120605/28267.html

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.