Javascript implementation prohibit right-clicking and F12 viewing source code _ javascript tips-js tutorial

Source: Internet
Author: User
This article mainly introduces the javascript code that disables right-click and F12 viewing source code. If you need code, you can refer to the function below. The Code is also very simple. There is not much nonsense here, and the source code is provided directly, you need to take it directly.

The Code is as follows:


Function click (e ){
If (document. all ){
If (event. button = 2 | event. button = 3) {alert ("welcome to the cold house. if you need any help, please contact the webmaster! Thank you for your cooperation !!! ");
Oncontextmenu = 'Return false ';
}
}
If (document. layers ){
If (e. which = 3 ){
Oncontextmenu = 'Return false ';
}
}
}
If (document. layers ){
Document. captureEvents (Event. MOUSEDOWN );
}
Document. onmousedown = click;
Document. oncontextmenu = new Function ("return false ;")

Document. onkeydown = document. onkeyup = document. onkeypress = function (){
If (window. event. keyCode = 123 ){
Window. event. returnValue = false;
Return (false );
}
}
<-- 123--112 is the number of code for the F1-F12 -->

This is to prevent others from reading your code!

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.