Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

javascript - How to disable (View Source) and (Ctrl + C ) from my site

Is there a chance to disable these two things from my site? (View Source) and (Ctrl + C )

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This isn't possible. You could try to somehow obfuscate the code, but you need to send something to client, don't you? You could use AJAX calls to load your html. This way, the source that the browser will show could be almost empty. However, there is nothing you can do to prevent an experienced user from viewing everything you are sending to the client. In fact there are so many tools he/she can use to reconstruct the page that any technique you will fight hard to apply, will only delay him/her for a couple of minutes.

Regarding the Ctrl-C you could add javascript to block it, but it is useless, since the user can always disable javascript. In fact many users will find interception of right-click very annoying.

All these could have a meaning if you are building an intranet application or you can ship an integrated browser for users to view the application. With public html, I believe it isn't even worth trying. One solution would be to build your application with flash or another plug-in. This way you can encrypt everything you've sent to the client.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...