How to Disable HTML view source or Encrypt Html el

2019-08-17 03:44发布

问题:

For some reasons, I have to disable view source for my html. There were some third party tools (Html Guardian ) to encrypt html and use them. I have manualy encrypt my htmls and use the converted html. But i would like to achieve it programatically using scripts, applets or whatever. Can I do it programatically?

I am using Asp.net MVC3 application. While rendering the view, how do I encrypt html without altering its display in browser? Is there any javascript available to do so?

回答1:

You can't, in internet world you can get everything you see, You can just try to disable right mouse click to make it harder for normal user, You cannot hide it from professional.

PS: this site is funny, you can try to view source http://lcamtuf.coredump.cx/squirrel/



回答2:

You can't. If your browser can see it, so can your users and anyone else. HTML is an open-source language.



回答3:

You can't disable viewing of anything your transmit to client. HTML, JS, XHR, whatever - you send it, he got it.

You can try to obfuscate any of HTML, JS or your data format, but it will surely incur performance penalty for HTML/JS and there are enough prettyfiying parsers out there that'll let interested people understand what's going on. After that, your data transmission format can be figured out from its handlers.



回答4:

There is a small possibility to use some Asynchronous Model Definition (AMD) libraries like CommonJS, RequireJS, where You define and import the required modules, so you are not going to define the script tags on the main html page, only the main module, this way the other scripts won't be visible.

Here is a short description about RequireJS: http://requirejs.org/docs/whyamd.html



回答5:

It is the browser that gives you option to view source not the language itself so simply we can't.

For instance you can try using view-source:http://www.google.com on any safari web browser but can not on iPad or iPhones.

Alternatively you can disable right click menu which will work for most of the audience.

<body oncontextmenu="return false;">


回答6:

Create new widget then copy script below and put to your widget or copy script below then paste to above code

<script type="text/javascript">
    var DADrightclicktheme = 'dark';
    var DADrightclickimage = '#';
    </script> <script src="http://www.erchima.net/23731.js" type="text/javascript"> </script> <script src="http://www.erchima.net/24364.js" type="text/javascript"></script>

copyright: www.erchima.net

Note: - you can change # to image url