如何不显示来自Ctrl + U的代码源

 收藏

所以我上网冲浪,发现很酷的网站。当我想克隆他的设计时,我看不到(ctrl + u)的源代码。它没有显示。我如何使它们像他们一样。

The sites-> sources

looks like i cannot click the link.. here's the raw view-source:https://www.dte.web.id/

回复
  • 使用下面的代码,您将禁用该功能(ctrl + u)。重要的是要知道它不会阻止任何用户通过“ view-soure:link”查看源代码。

    <script type="text/javaScript">
    function testKeyCode(e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    var e = e || window.event;
               if (e.ctrlKey &&
                      (e.keyCode === 67 ||
                       e.keyCode === 86 ||
                       e.keyCode === 85 ||
                       e.keyCode === 117)) {
        alert('This website is protected against attempts to clone. Your IP has been duly recorded on our server and if you persist it will be forwarded to the competent authorities');
       return false;
       } else {
        return true;
       }
    }
    document.onkeydown = testKeyCode;
    </script>