【问题标题】:How to not show code source from ctrl + u如何不显示来自 ctrl + u 的代码源
【发布时间】:2020-07-07 19:22:05
【问题描述】:
所以我在网上冲浪,发现了很酷的网站。当我想克隆他的设计时,我无法通过 (ctrl+u) 看到源代码。它没有显示。我怎样才能让它像他们一样。
网站-> sources
看起来我无法点击链接.. 这是原始的view-source:https://www.dte.web.id/
【问题讨论】:
标签:
html
css
xhtml
blogger
【解决方案1】:
使用下面的代码,您将禁用该功能 (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>