这个弹窗个人觉得很好看,一般只有“复制提醒(附带复制失败提醒)”、“禁用F12”、“禁用鼠标右键”,这里把常见的“禁用Ctrl+U”、“禁用Ctrl+S”、“禁用Ctrl+Shift+I”等都分享给大家。
效果演示
代码路径
1./wp-content/themes/zibll/header.php
加入以下引入代码
<!-- 引入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">
2.Zibll主题设置 >> 全局&功能 >> 自定义代码 >> 自定义javascript代码 里面加入以下代码
/*Right click prohibited*/
document.oncontextmenu = function () {
new Vue({
data:function(){
this.$notify({
title:"嗯?没有右键菜单",
message:"复制请用键盘快捷键[Ctrl+C]",
position: 'bottom-right',
offset: 50,
showClose: false,
type:"warning"
});
return{visible:false}
}
})
return false;
}
/*Prohibit F12*/
document.onkeydown = function () {
if (window.event && window.event.keyCode == 123) {
event.keyCode = 0;
event.returnValue = false;
new Vue({
data:function(){
this.$notify({
title:"呃!别瞎按",
message:"你按这个想干嘛!再按就找不到我咯",
position: 'bottom-right',
offset: 50,
showClose: false,
type:"error"
});
return{visible:false}
}
})
return false;
}
/*Prohibit Ctrl+U*/
if (event.ctrlKey && window.event.keyCode == 85) {
new Vue({
data: function() {
this.$notify({
title: "嘿!Brother",
message: "老弟,源码得换方式获取哦~",
position: 'bottom-right',
offset: 50,
showClose: true,
type: "error"
});
return {
visible: false
}
}
})
return false;
}
/*Prohibit Ctrl+S*/
if (event.ctrlKey && window.event.keyCode == 83) {
new Vue({
data: function() {
this.$notify({
title: "哎!你瞧瞧你",
message: "网页得换方法保存哦~",
position: 'bottom-right',
offset: 50,
showClose: true,
type: "error"
});
return {
visible: false
}
}
})
return false;
}
/*Prohibit Ctrl+Shift+I*/
if ((event.ctrlKey) && (event.shiftKey) && (event.keyCode == 73)) {
event.keyCode = 0;
event.returnValue = false;
new Vue({
data:function(){
this.$notify({
title:"呐!这个也不行",
message:"还是按点别的吧!",
position: 'bottom-right',
offset: 50,
showClose: false,
type:"error"
});
return{visible:false}
}
})
return false;
}};
/*Copy Remind*/
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
}
}
})
})
© 版权声明
THE END
暂无评论内容