这个弹窗个人觉得很好看,包含“复制提醒”、“禁用F12”、“禁用鼠标右键”“禁用Ctrl+U”、“禁用Ctrl+S”、“禁用Ctrl+Shift+I”等都分享给大家,新增了“禁用Ctrl+P”、“禁用Ctrl+F”
首先这几个,为了防止小白,但是如果真想扒你的,是真的防不住的,所以本篇文章就是分享一个防止小白的一个弹窗
部署教程
首先我们要将下面的代码放到/wp-content/themes/zibll/header.php
或者在子比后台=>>自定义代码=>>自定义底部HTML代码
两个方式都可以的

<!-- 引入VUE -->
<script src="https://unpkg.com/vue@2.6.14/dist/vue.min.js"></script>
<!-- 引入样式 -->
<script src="https://unpkg.com/element-ui@2.15.6/lib/index.js"></script>
<!-- 引入组件库 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui@2.15.6/packages/theme-chalk/lib/index.css">
很多小白不懂为什么要把上面代码放里面,因为上面的代码是为了用户如果按禁用按钮,他会提示,相当于提示代码吧
第二步
我们把下面的代码放到/wp-content/themes/zibll/header.php
文件里面,记住放后台有的会不生效,所以放到这个里面,放到底部好一点,还有我这个人不喜欢去收费,我就设置一下评论可见吧
JS代码
<script>
document.onkeydown = function(event) {
if (event.ctrlKey && event.keyCode == 83) { // Ctrl + S
event.preventDefault();
new Vue({
data: function() {
this.$notify({
title: "哎!你瞧瞧你",
message: "网页得换方法保存哦~",
position: 'bottom-right',
offset: 50,
showClose: true,
type: "error"
});
return {
visible: false
}
}
})
return false;
}
if (event.ctrlKey && event.keyCode == 85) { // Ctrl + U
event.preventDefault();
new Vue({
data: function() {
this.$notify({
title: "嘿!Brother",
message: "老弟,源码得换方式获取哦~",
position: 'bottom-right',
offset: 50,
showClose: true,
type: "error"
});
return {
visible: false
}
}
})
return false;
}
if (event.ctrlKey && event.keyCode == 70) { // Ctrl + F
event.preventDefault();
new Vue({
data: function() {
this.$notify({
title: "嘿!Brother",
message: "老弟,别搜了",
position: 'bottom-right',
offset: 50,
showClose: true,
type: "error"
});
return {
visible: false
}
}
})
return false;
}
if (event.ctrlKey && event.keyCode == 80) { // Ctrl + P
event.preventDefault();
new Vue({
data: function() {
this.$notify({
title: "嘿!Brother",
message: "老弟,别打印了",
position: 'bottom-right',
offset: 50,
showClose: true,
type: "error"
});
return {
visible: false
}
}
})
return false;
}
if (event.ctrlKey && event.shiftKey && event.keyCode == 73) { // Ctrl + Shift + I
event.preventDefault();
new Vue({
data: function() {
this.$notify({
title: "呐!这个也不行",
message: "还是按点别的吧!",
position: 'bottom-right',
offset: 50,
showClose: false,
type: "error"
});
return {
visible: false
}
}
})
return false;
}
if (event.keyCode == 123) { // F12
event.preventDefault();
new Vue({
data: function() {
this.$notify({
title: "呃!别瞎按",
message: "你按这个想干嘛!F12已经禁止咯",
position: 'bottom-right',
offset: 50,
showClose: false,
type: "error"
});
return {
visible: false
}
}
})
return false;
}
};
</script>
<script>
document.addEventListener("copy", function(e) {
new Vue({
data: function() {
if((window.getSelection ? window.getSelection() : document.selection.createRange().text) != ''){
this.$notify({
title: "叮!复制成功",
message: "若要转载请务必保留原文链接!谢谢~",
position: 'bottom-right',
offset: 50,
showClose: true,
type: "success"
});
}else{
this.$notify({
title: "咦?复制失败",
message: "啊噢...你没还没选择内容呢!",
position: 'bottom-right',
offset: 50,
showClose: true,
type: "success"
});
}
return {
visible: false
}
}
})
})
</script>
本人子主题内功能:

- 最新
- 最热
只看作者