Javascript code _ javascript tips for right-clicking, Ctrl + n, shift + F10, F5 refresh, and Backspace

Source: Internet
Author: User
Javascript code that shields the right-click, Ctrl + n, shift + F10, F5 refresh, and backspace keys
Function KeyDown (){
If (window. event. altKey )&&
(Window. event. keyCode = 37) | // mask Alt + direction key seek
(Window. event. keyCode = 39) {// mask Alt + direction key →
Alert ("you are not allowed to use ALT + arrow 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 key pop-up warning box is displayed, press and hold the Alt key,
With the mouse clicked off the warning box, this blocking method will become invalid. If
Which of the following methods does the master really block the Alt key. */

If (event. keyCode = 8) | // shield the unregeed deletion key
(Event. keyCode = 116) | // block the F5 refresh key
(Event. ctrlKey & event. keyCode = 82) {// Ctrl + R
Event. keyCode = 0;
Event. returnValue = false;
}
If (event. ctrlKey) & (event. keyCode = 78) // block Ctrl + n
Event. returnValue = false;
If (event. shiftKey) & (event. keyCode = 121) // block shift + F10
Event. returnValue = false;
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 ;}
}



Function init ()
{
Try {announceDiv. innerText = announce;} catch (e ){}
}
Window. onload = init;

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.