代码之家  ›  专栏  ›  技术社区  ›  Linda

html页没有复制脚本

  •  1
  • Linda  · 技术社区  · 14 年前

    我的一个客户希望网站上有一个禁止复制的脚本,以防止人们从页面上复制文本。有没有跨浏览器的方法可以做到这一点?我可能只看一个JavaScript方法。我知道这可以关闭的人有一点诀窍,但会做的大多数情况下。

    4 回复  |  直到 14 年前
        1
  •  2
  •   Sachin R    14 年前
    <script language="JavaScript"> 
    // distributed by http://hypergurl.com <!-- var popup="Sorry, right-click 
    is disabled.\n\nThis Site Copyright ©2000"; function noway(go) { if 
    (document.all) { if (event.button == 2) { alert(popup); return false; } } if (document.layers) 
    { if (go.which == 3) { alert(popup); return false; } } } if (document.layers) 
    { document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=noway; // --> 
    </script>
    
    
    
    <script language="JavaScript1.1"> 
    // distributed by http://www,hypergurl.com <!-- var debug = true; function 
    right(e) { if (navigator.appName == 'Netscape' && (e.which == 3 || e.which 
    == 2)) return false; else if (navigator.appName == 'Microsoft Internet Explorer' 
    && (event.button == 2 || event.button == 3)) { alert('This Page is fully 
    protected!'); return false; } return true; } document.onmousedown=right; if (document.layers) 
    window.captureEvents(Event.MOUSEDOWN); window.onmousedown=right; //--></script>
    
        2
  •  3
  •   Anax    14 年前

    ton of resources 关于这个请求。记住,一个有决心的用户总是能够从网页上复制文本。

        3
  •  2
  •   RvdK    14 年前

    不是答案而是我对这个问题的看法:

    javascript将阻止用户进行选择,但用户会感到恼火(e、 g.我有时选择文本以使阅读更容易,而不是复制文本)

    人们仍然可以通过HTML源代码/DOM获取文本。 人们可以重新输入文本或制作图片并使用OCR。

        4
  •  2
  •   takrl cck    13 年前
    <script language=JavaScript>
      var message="!!YOU CANNOT COPY ANY TEXT OR IMAGE FROM THIS SITE!";
      function clickIE4()
      {
        if (event.button==2)
        {
          alert(message);
          return false;
        }
      }
      function clickNS4(e)
      {
        if (document.layers||document.getElementById&&!document.all)
        {
          if (e.which==2||e.which==3)
          {
            alert(message);
            return false;
          }
        }
      }
    
      if (document.layers)
      {
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown=clickNS4;
      }
      else if (document.all&&!document.getElementById)
      {
        document.onmousedown=clickIE4;
      }
      document.oncontextmenu=new Function("alert(message);return false")
    </script>
    </head>
    <body>