验证中...
私信发送成功
检测到您已登录开源中国,是否 一键登录码云
语言: JavaScript
分类: 编程语言基础
最后更新于 2017-09-20 16:28
gistfile1.txt
原始数据 复制代码
//若是你不想别人扒掉你的模板,可以把这段js代码加到你网页上,即可屏蔽鼠标右键菜单、复制粘贴、选中等
//屏蔽右键菜单
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;
}
}

评论列表( 4 )

1526721_youlanw_admin
优蓝 2017-09-11 17:06

防不了

小阳007 2017-09-14 10:44

f12 什么代码都给你扒了,包括你这个代码也给扒了

1091230_hjx2016
〆贤 2017-09-15 13:15

哈哈,只能过滤下小白

929129_xiaojunhao
西風悲畫扇 2017-09-20 16:28

f12 也可以按键监听干掉的

你可以在登录后,对此项目发表评论

People Icon_close
Float_left Icon_close