html - 如何不显示来自 ctrl + u 的代码源
问题描述
所以我在网上冲浪,发现了很酷的网站。当我想克隆他的设计时,我无法通过 (ctrl+u) 看到源代码。它没有显示。我如何让它像他们一样。
网站->来源
看起来我无法点击链接..这是原始的view-source:https://www.dte.web.id/
解决方案
使用下面的代码,您将禁用该功能 (ctrl + u)。重要的是要知道它不会阻止任何用户通过“查看源代码:链接”查看源代码
<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>
推荐阅读
- html - 居中表格
- maven - 如何将一个存储库项目 jar 包含到另一个存储库项目中
- javascript - 从已解析的 CSV 数组中删除重复项
- amazon-web-services - 如何调用 lambda 的 cron 调用
- c - C99 | (BItfield)结构中的结构不能与 name1.name2.variable 一起选择
- sql - 我如何找到 SQL 中最常用的工具
- javascript - 当我尝试教程时,React 不断中止安装
- c# - 将 c# windows 应用程序和 web 应用程序放在一起
- c# - 如何在 c# windows 应用程序中使用 RichEdit20W Control?
- haskell - 回答这个 Haskell 表达式