如何隐藏CTRL + U查看源代码&禁用右键单击和文本复制?

时间:2017-06-05 07:49:09

标签: html firefox hide

任何人都可以使用隐藏CTRL + U的解决方案并在Firefox中右键单击吗?

1 个答案:

答案 0 :(得分:0)

我终于找到了上述查询的解决方案。在Firefox中尝试以下代码也可以正常工作..

<script type='text/javascript'>
        var isCtrl = false;
        document.onkeyup=function(e)
        {
            if(e.which == 17)
            isCtrl=false;
        }
        document.onkeydown=function(e)
        {
            if(e.which == 17)
            isCtrl=true;
            if((e.which == 85) || (e.which == 80) || (e.which == 123) || (e.which == 67) && (isCtrl == true))
            {
                return false;
            }
        }
        var isNS = (navigator.appName == "Netscape") ? 1 : 0;
        if(navigator.appName == "Netscape") document.captureEvents(Event.MOUSEDOWN||Event.MOUSEUP);
        function mischandler(){
            return false;
        }
        function mousehandler(e){
            var myevent = (isNS) ? e : event;
            var eventbutton = (isNS) ? myevent.which : myevent.button;
            if((eventbutton==2)||(eventbutton==3)) return false;
        }
        document.oncontextmenu = mischandler;
        document.onmousedown = mousehandler;
        document.onmouseup = mousehandler;
</script>

<body oncontextmenu="return false;">