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



本网站中使用了哪个脚本?我们无法查看源代码(CTRL U)和右键单击鼠标。我想在我的网站上添加这样的脚本。您能提供脚本吗?

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;
  

该页面使用以下代码:

 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>

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

最新更新