Html 如何隐藏我的源代码以免被复制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12543704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to hide my source code so to not be copied
提问by Claudiu Creanga
I was recently informed by someone that my website was copied. When I looked at the linked that he gave me I so that the site was identic to mine except for the logo and text. Is there a way to hide my code? Or to make it impossible to right click on my page? I saw on some websites that if you go to http://example.com/images/it will show access denied, not a list with all your images...How do they do it? Thank you!
最近有人通知我我的网站被复制了。当我查看他给我的链接时,除了徽标和文字外,该网站与我的网站完全相同。有没有办法隐藏我的代码?还是无法右键单击我的页面?我在一些网站上看到,如果您访问http://example.com/images/它将显示访问被拒绝,而不是包含所有图像的列表...他们是如何做到的?谢谢!
采纳答案by NullPoiиteя
Don't do this!It makes no sense to do this, since the user can disable the script, and there are many tools like Firebug by which a user can see the code.
不要这样做!这样做是没有意义的,因为用户可以禁用脚本,并且有许多工具,例如 Firebug,用户可以通过它们查看代码。
The best way to keep safe the store is installing a security camera while leaving the doors open.
确保商店安全的最佳方法是在开门的同时安装安全摄像头。
You can simply disable the right click by following:
您可以通过以下方式简单地禁用右键单击:
<body oncontextmenu="return false">
...
</body>
or
或者
<script language="javascript">
document.onmousedown = disableclick;
status = "Right Click Disabled";
Function disableclick(e)
{
if(event.button == 2)
{
alert(status);
return false;
}
}
</script>
The code above is from this article
上面的代码来自这篇文章
回答by Grant Thomas
You can do stuff which amounts to security through obscurity, but the only way to prevent your client-side web source from being copyable is to not push it down the wire, to not deliver it in the first place, shut down your website.
您可以通过默默无闻来做一些相当于安全的事情,但防止您的客户端 Web 源可复制的唯一方法是不要将其推下网络,首先不要交付它,关闭您的网站。
回答by Will Palmer
No, there is no way to hide one's code on the web. If you're sending information to the client-side, that information can be copied. That's not merely a fact of the web, that's a fact of information theory. The only option for cases like this is not prevention, but detection. Many services exist to help in these situations.
不,没有办法在网络上隐藏自己的代码。如果您要向客户端发送信息,则可以复制该信息。这不仅是网络的事实,也是信息论的事实。此类情况的唯一选择不是预防,而是检测。许多服务可以帮助解决这些情况。
Depending on your web host, preventing the listing of files in an images/
directory, for example, may be done by adding an .htaccess
file with appropriate restrictions, or disabling directory listings from within your host's panel. The key words you need are "disabling directory listings". Talk to your webhost's support for more details, this is a very common request, so they likely already know exactly how to help you.
根据您的 Web 主机,images/
例如,可以通过添加.htaccess
具有适当限制的文件或从主机面板中禁用目录列表来阻止目录中的文件列表。您需要的关键词是“禁用目录列表”。与您的虚拟主机的支持人员联系以获取更多详细信息,这是一个非常常见的请求,因此他们可能已经确切地知道如何为您提供帮助。
Note that this will only prevent the listingof images in a convenient form. If they are referenced on other pages on your site, they can still be easily downloaded.
请注意,这只会阻止以方便的形式列出图像。如果它们在您网站的其他页面上被引用,它们仍然可以轻松下载。
回答by Aron Jay
In that case, probably they have an access to your ftp account. If I were you I will change my ftp credentials.
在这种情况下,他们可能可以访问您的 ftp 帐户。如果我是你,我会更改我的 ftp 凭据。
And also, there are tools that would really copy all of the websites content, including its source codes. One notable is IDM or Internet Download Manager http://www.internetdownloadmanager.com/which has a Site Grabber feature.
而且,还有一些工具可以真正复制所有网站内容,包括其源代码。一个值得注意的是 IDM 或 Internet 下载管理器http://www.internetdownloadmanager.com/,它具有站点抓取功能。
回答by akton
Hiding the right click handler only stops honest people from getting the page source and not those using tools like wgetor curl. You can obfuscate or minify your JavaScript (such as using Google Closure) but, if the browser needs to get access to the code or content, so can someone who is malicious.
隐藏右键单击处理程序只会阻止诚实的人获取页面源代码,而不会阻止那些使用wget或curl等工具的人。您可以混淆或缩小您的 JavaScript(例如使用Google Closure),但是,如果浏览器需要访问代码或内容,那么恶意的人也可以这样做。
回答by chike
just create an empty index.html page and upload to your images folder, that solves it, so whenever they use /images
..
只需创建一个空的 index.html 页面并上传到您的图像文件夹即可解决它,因此无论何时他们使用/images
..
回答by KroKite
There is no full proof way.
没有完全证明的方法。
But here is some strategy that can be employed to hide source code like using "window.history.pushState()"
但是这里有一些可以用来隐藏源代码的策略,比如使用“ window.history.pushState()”
Detail here - http://freelancer.usercv.com/blog/28/hide-website-source-code-in-view-source-using-stupid-one-line-chinese-hack-code
回答by Andrew
imho, it is impossible. Even if you block right click, F12, Ctrl+C/V, or others shortcut to copy, you can still counter with disable JavaScript and copy the the page source.
恕我直言,这是不可能的。即使您阻止了右键单击、F12、Ctrl+C/V 或其他快捷方式进行复制,您仍然可以通过禁用 JavaScript 来反击并复制页面源。