How to prevent page source view using javascript?

How to prevent page source code from loading with File> Save As?

+4
source share
5 answers

You can not. This page actually loads when you view it in a browser. If you want to protect the content, you might be confusing the source, and depending on what you are doing, you might render the page inoperable after it loads (i.e., force some page behavior to rely on an Ajax request to your server). But there will always be workarounds.

+4
source

This is impossible, and you should not even try it , because:

  • , , , , , .
  • , , ( " ? , , ." )

Microsoft, Amazon Co., , DeviantArt: , , (= ) , , ,

, , .

: , , .

+30

. , , , - .

+12

, javascript, , // script - .

Try this javascript obfuscator . It seems to work very well!

As a side note, this will not stop someone who is defined, but will certainly slow them down.

+9
source
<!-- Right Click Disable -->
<script type="text/javascript">
<!-- 
var message=""; 
function clickIE() {if (document.all) {(message);return false;}} 
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) { 
if (e.which==2||e.which==3) {(message);return false;}}} 
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;} 
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;} 

document.oncontextmenu=new Function("return false") 
</script>
<!-- Right Click Disable -->
0
source

Source: https://habr.com/ru/post/1719771/


All Articles