JavaScript 控制鼠标右键功能含:屏蔽右键菜单、屏蔽粘贴、屏蔽复制、屏蔽剪切、屏蔽选中

JavaScript 控制鼠标右键功能含:屏蔽右键菜单、屏蔽粘贴、屏蔽复制、屏蔽剪切、屏蔽选中

最近写了一个摄影素材的站点,网友只能浏览,为了自己版权利益,防止网友在网站中直接下载和引用未经本人同意的产品素材,特意写了几个JavaScript方法屏蔽电脑的右键功能。全网最简单的方法,屏蔽鼠标右键功能,防止复制和下载,记得收藏哦!

1、屏蔽右键菜单

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;

}

}

2、屏蔽粘贴

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;

}

}

3、屏蔽复制

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;

}

}

4、屏蔽剪切

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;

}

}

5、屏蔽选中

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;

}

}

相关推荐

提莫成为第四位永久免费英雄
365bet正网开户

提莫成为第四位永久免费英雄

⏳ 06-29 👁️ 4615
C罗渴望参加下一届世界杯后再退役的梦想追寻
beat365官方网站登录

C罗渴望参加下一届世界杯后再退役的梦想追寻

⏳ 11-05 👁️ 2196