首页建站经验 JS如置网站屏蔽右键菜单,屏蔽复制,屏蔽选中的代码是什么?

JS如置网站屏蔽右键菜单,屏蔽复制,屏蔽选中的代码是什么?

网站屏蔽鼠标右键,可以屏蔽复制,屏蔽选中,屏蔽剪切。下面是青青模板网整理的关于如何屏蔽鼠标右键的解决方案和思路,方便新手站长们在利用帝国cms建网站的时候,可以少走一些弯路…

网站屏蔽鼠标右键,可以屏蔽复制,屏蔽选中,屏蔽剪切。下面是青青模板网整理的关于如何屏蔽鼠标右键的解决方案和思路,方便新手站长们在利用帝国cms建网站的时候,可以少走一些弯路。

将下列代码复制粘贴到模板-公共模板变量-底部即可

<script type="text/javascript">
//屏蔽右键菜单
____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.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;
    }
}
 
//屏蔽复制
____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.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;
    }
}
</script>




 

本文来自网络,不代表1号站长-站长学院|资讯交流平台立场。转载请注明出处: https://www.1cn.cc/jianzhan/jingyan/39939.html
上一篇 关于WEB服务器安全浅谈!做好以下几点,服务器可最小程度免于入侵挂马!
下一篇 企业真的合适用自助建站吗?自助建站适合推广吗
zoulin

作者: zoulin

这里可以再内容模板定义一些文字和说明,也可以调用对应作者的简介!或者做一些网站的描述之类的文字或者HTML!

为您推荐

评论列表()

    联系我们

    联系我们

    0898-88888888

    在线咨询: QQ交谈

    邮箱: email@wangzhan.com

    工作时间:周一至周五,9:00-17:30,节假日休息

    关注微信
    微信扫一扫关注我们

    微信扫一扫关注我们

    关注微博
    返回顶部