Examples of blocking in js

Source: Internet
Author: User

Js Shielding Effect
Copy codeThe Code is as follows:
/** Block F1 help */
Window. onhelp = function () {return false ;}
/**
* Block F5, Ctrl + N, Shift + F10, Alt + F4
* If You Want To shield other keys, find the corresponding keyCode and follow this method.
*/
Document. onkeydown = function (event ){
Event = window. event | event;
If (event. keyCode = 116 | (event. ctrlKey & event. keyCode = 78) | (event. shiftKey & event. keyCode = 121) | (event. altKey & event. keyCode = 115 )){
Event. keyCode = 0;
Event. returnvalue = false;
}
}
/** Right-click the block button */
Document. oncontextmenu = function () {return false ;}
// Or
Document. onmousedown = function (event ){
Event = window. event | event;
If (document. all & event. button = 2 ){
Event. returnvalue = false;
}
}
/**
* Block the "back" function (<a href = "javascript: replaceLocation ('HTTP: // www.google.com ')" mce_href = "javascript: replaceLocation ('HTTP: // www.google.com ') "> Google </a>)
* @ Param url the URL to be redirected
*/
Function replaceLocation (url ){
Document. location. replace (url );
}
/** Block selected webpage content */
Document. onselectstart = function () {return false ;}
/** Block and copy webpage content */
Document. body. oncopy = function () {return false ;}
/** Shield and cut webpage content */
Document. body. oncut = function () {return false ;}
/** Hide and paste content on the webpage */
Document. body. onpaste = function () {return false ;}
/** Shield the clipboard screen (without stopping the clipboard )*/
Window. setInterval ('window. clipboardData ("Text", "") ', 100 );
/**
* Shielding the source file (<body onload = clear ()>)
*/
Function clear (){
Var source = document. body. firstChild. data;
Document. open ();
Document. close ();
Document. body. innerHTML = source;
}
/**
* Blocking js errors
*/
Function KillError ()
{
Return true;
}
Window. onerror = KillError;

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.