如何禁用源代码并右键单击鼠标?

时间:2016-12-21 10:54:40

标签: javascript disabled-control source-code-protection

this website中使用了哪个脚本?我们无法查看源代码(Ctrl + U)和右键单击鼠标。我想像这个脚本一样添加到我的网站。 你能提供一下脚本吗?

2 个答案:

答案 0 :(得分:0)



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 == 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;
  




答案 1 :(得分:0)

该页面使用以下代码:



 document.oncontextmenu = function(e) {
   var t = e || window.event;
   var n = t.target || t.srcElement;
   if (n.nodeName != "A") return false
 };
 document.ondragstart = function() {
   return false
 };


 function disableSelection(e) {
   if (typeof e.onselectstart != "undefined") e.onselectstart = function() {
     return false
   };
   else if (typeof e.style.MozUserSelect != "undefined") e.style.MozUserSelect = "none";
   else e.onmousedown = function() {
     return false
   };
   e.style.cursor = "default"
 }
 window.onload = function() {
   disableSelection(document.body)
 }

<div style="height: 150; width: 150">
  <a href="link1.html">link 1</a>
</div>
&#13;
&#13;
&#13;

顺便说一句,您无法保护Javascript源代码免遭被盗或查看,因为访问该页面的人必须能够查看该脚本才能运行它。