禁用F12
<script>
document.onkeydown = function ( e ) {
var currKey = 0,
evt = e || window.event;
currKey = evt.keyCode || evt.which || evt.charCode;
if ( currKey == 123 ) {
window.event.cancelBubble = true;
window.event.returnValue = false
}
}
</script>
禁用鼠标右键
<script>
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
}
}
</script>
禁止复制
<script>
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;
}
}
</script>
禁止剪切
<script>
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;
}
}
</script>
禁止选中
<script>
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;
}
}
</script>
历史上的今天
2020年:Wireshark抓包新手使用教程(0条评论)
请博主喝杯咖啡呢,谢谢^_^
如果本文“对您或有帮助”,欢迎随意打赏,以资鼓励继续创作!
原创文章《JS禁止鼠标右键及F12禁止查看源代码及禁止其他操作》,作者:笔者 徐哲,未经允许不得转载。
转载或复制时,请注明出处:https://www.xuxiaokun.com/3038.html,本文由 Mr.xu 博客网 整理。
本站资源下载仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。