A fun to block other people's censorship element F12 right click and other copy and paste, etc.

Sometimes there are some little secrets or other things in the private personal pages that I write. I don’t want others to review the elements, so I provide a piece of code that prevents others from reviewing the elements (I personally prefer to make interesting things and play with them. )

//屏蔽右键菜单
document.oncontextmenu = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
}
//屏蔽粘贴
document.onpaste = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
}
//屏蔽复制
document.oncopy = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
}
//屏蔽剪切
document.oncut = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if(!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
}catch (e){
return false;
}
}
//屏蔽选中
document.onselectstart = function (event){
if(window.event){
event = window.event;
}try{
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")){
return false;
}
return true;
} catch (e) {
return false;
}
}

 

But the above can inspect elements with F12, so here is a piece of code to disable F12 

 

document.onkeydown = function(){ 

if(window.event && window.event.keyCode == 123) {
alert("F12 is disabled");
event.keyCode=0;
event.returnValue=false;
}
if(window. event && window.event.keyCode == 13) {
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 8) {
alert(str+"\nPlease use the Del key for character Delete operation!");
window.event.returnValue=false;
}

}

Note: These are only for ordinary people, ordinary people, ordinary people (three important things to say)! ! !

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324978922&siteId=291194637