HTML网页屏蔽f12、右键、禁止复制与禁止查看源代码

//禁用F12

window.onkeydown = window.onkeyup = window.onkeypress = function (event) {

    // 判断是否按下F12,F12键码为123

    if (event.keyCode == 123) {

    event.preventDefault(); // 阻止默认事件行为

    window.event.returnValue = false;

    }

}

//禁用调试工具

var threshold = 160; // 打开控制台的宽或高阈值

// 每秒检查一次

var check = setInterval(function() {

    if (window.outerWidth – window.innerWidth > threshold || 

        window.outerHeight – window.innerHeight > threshold) {

        // 如果打开控制台,则刷新页面

        window.location.reload();

    }

}, 1000)

//屏蔽右键菜单

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;

    }

}

//屏蔽选中

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;

    }

}

//屏蔽复制

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;

    }

}

//屏蔽剪贴

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;

    }

}

 

//屏蔽粘贴

document.onpaste = 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;

    }

}

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

免责声明:本文系转载自互联网,版权归原作者所有;旨在传递信息,不代表中站源码网的观点和立场。如有侵权,请联系我们删除!qin@ceccz.com

中站源码网-网络情报局 CMS教程 HTML网页屏蔽f12、右键、禁止复制与禁止查看源代码 https://web.ceccz.com/cmsjc/3833.html

中站网

常见问题
  • 本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
查看详情
  • 最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议换浏览器下载!
查看详情

相关文章

评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务

 
HTML网页屏蔽f12、右键、禁止复制与禁止查看源代码-海报

分享本文封面