WordPress主题 禁止用户获取代码教程-子比可用2年前更新21860 之前网站分享了如何禁止右键,今天来分享一下WordPress如何禁止用户以各种方式获取代码,其实跟禁止邮件类似,禁止用户操作以获取相关信息,比如禁止复制,禁止右键等,这个对弹出的对话框尽心了美化,个人还是比较喜欢的,只要是WordPress都可以使用,子比,7B2啥的都可以使用,放在合适的位置即可。 使用方法 引用CSS,把以下代码添加到子比的主题设置-自定义代码里的自定义底部HTML代码里即可。 <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.6/lib/index.js"></script> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.15.6/packages/theme-chalk/lib/index.css"> 把以下代码添加到子比的主题设置-自定义代码里的自定义javascript代码里即可。 站长已亲测贴心的标上了注释。 //禁止用户以各种方式获取代码 /*ctrl+u*/ document.onkeydown=function(){if(event.ctrlKey&&window.event.keyCode==85){new Vue({data:function(){this.$notify({title:"嘿!别瞎按",message:"老弟,想偷我源码?~",position:'bottom-right',offset:50,showClose:true,type:"error"});return{visible:false}}}) return false;} /*f 12*/ if(window.event&&window.event.keyCode==123){event.keyCode=0;event.returnValue=false;new Vue({data:function(){this.$notify({title:"嘿!Bingo~",message:"老弟,试试 Alt+Shift+Fn+F4",position:'bottom-right',offset:50,showClose:true,type:"error"});return{visible:false}}}) return false;} /*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;} /*ctrl+shift+i*/ if((event.ctrlKey)&&(event.shiftKey)&&(event.keyCode==73)){new Vue({data:function(){this.$notify({title:"嘿!哈哈哈",message:"老弟,调试方法也得换换哟~",position:'bottom-right',offset:50,showClose:true,type:"error"});return{visible:false}}}) return false;} /*f5*/ if(window.event&&window.event.keyCode==116){event.keyCode=0;event.returnValue=false;new Vue({data:function(){this.$notify({title:"嘿!喂喂喂",message:"浏览器自带刷新按钮不香吗?",position:'bottom-right',offset:50,showClose:true,type:"warning"});return{visible:false}}}) return false;}} /*复制tips*/ document.addEventListener("copy",function(e){new Vue({data:function(){this.$notify({title:"叮!复制成功",message:"若要转载必须保留本站原文链接!",position:'bottom-right',offset:50,showClose:true,type:"success"});return{visible:false}}})}) /* 禁用右键菜单并提醒 */ document.oncontextmenu = function (){new Vue({data:function(){this.$notify({title:"嘿!没有右键菜单",message:"复制请用键盘快捷键 Ctrl+C",position:'bottom-right',offset:50,showClose:true,type:"warning"});return{visible:false}}}) return false;} 温馨提示:本文最后更新于2023-05-28 19:12:45,某些文章具有时效性,若有错误或已失效,请私信客服或联系知新社长。 © 版权声明文章版权归作者所有,未经允许请勿转载。 四月 27 知岛上的今时往日 2024:子比主题美化-小工具标题美化 (46)2024:WordPress在文章内容中对文字加模糊隐藏效果 (15)2024:判断是否在微信浏览器打开 (1)2024:给WordPress网站添加一个文章日历页面 (0)2024:子比主题美化-给顶部幻灯片组件添加一组图标引导栏目 (3) THE END子比主题教程之家网站/配置/代码# 子比 喜欢就支持一下吧点赞0 分享QQ空间微博QQ好友海报分享复制链接收藏2