屏蔽F12

1.事先引入layer.js来提示信息,至后台-开发者设置-自定义输出body 尾部的HTML代码

/*禁止F12引入js*/
<script src="https://lib.baomitu.com/layer/3.1.1/layer.js"></script>

2.将以下代码添加至后台-开发者设置-自定义JavaScript

/*禁止F12*/
document.onkeydown = function(){
    if(window.event && window.event.keyCode == 123) {
        layer.msg("F12被禁用");
        event.keyCode=0;
        event.returnValue=false;
    }
}

禁止复制

代码:

/*禁止复制*/
<body onmousemove=HideMenu() oncontextmenu="return false" 
ondragstart="return false" 
onselectstart ="return false" 
onselect="document.selection.empty()" 
oncopy="document.selection.empty()" 
onbeforecopy="return false" 
onmouseup="document.selection.empty()">
</body>

复制上面的代码

进入后台——开发者设置——自定义输出body 尾部的HTML代码

来源:陶小桃blog

最后修改:2022 年 03 月 28 日
如果觉得我的文章对你有用,请随意赞赏