Home » Html » How to hide html source & disable right click and text copy?

How to hide html source & disable right click and text copy?

Posted by: admin November 30, 2017 Leave a comment

Questions:

The following website has both right click and view source disabled.

http://www.immihelp.com/visitor-visa/sponsor-documents.html

Can anyone shine some light on how this is possible?

Answers:

The following website has both right click and view source disabled.

They fooled you. Just scroll down in view-source.

Furthermore, employing such tactics marks you as unprofessional. Don’t do it.

Questions:
Answers:

They do this with some basic javascript, but this does not actually hide your HTML source! In many browsers you can simply go to view->source on the menu. Even if you couldn’t, it is trivial to simply load up a debugging proxy like Fiddler, or packet-sniff the connection.

It is impossible to effectively hide the HTML, JavaScript, or any other resource sent to the client. Impossible, and isn’t all that useful either.

Furthermore, don’t try to disable right-click, as there are many other items on that menu (such as print!) that people use regularly.

Questions:
Answers:

Hiding HTML source isn’t really possible. Disabling right-click only frustrates users who wish to do something constructive with your content (copy/paste content or forms, or print, for example).

If you’re running a server-side scripting language you could obfuscate or minify the HTML, CSS and Javascript. This will make it harder for someone to copy your code or see how you’ve achieved certain effects.

Questions:
Answers:

It’s a horrible thing to do, as everybody else has said, but if you really are intent on doing it, use this code, and put a load of returns at the top of the page’s source:

<html>
  <head>
    <script>
      function disableClick(){
        document.onclick=function(event){
          if (event.button == 2) {
            alert('Right Click Message');
            return false;
          }
        }
      }
    </script>
  </head>
  <body onLoad="disableClick()">
  </body>
</html>

Questions:
Answers:

You can still view the source on the website by going to View > Page Source from the toolbar in firefox. Or View > source in IE.

The right-click is disabled via javascript. The source for the javascript is:

http://www.immihelp.com/common/utils.js

Questions:
Answers:
 <body oncontextmenu="return false">

Use this code to disable right click.

Questions:
Answers:

Believe me, no one wants your source as much as you may think they do. When you decided to develop web pages, you became an open source developer.

It’s not possible to disable viewing a pages source. You can attempt to circumvent unknowledgeable users from seeing the source, but it won’t stop anyone who understands how to use menu’s or shortcut keys. Your best bet is to develop your site in a manner that will not be compromised by someone seeing your source. If you’re attempting to hide it for any other reason than to protect your intellectual property, then you’re doing something wrong.

Questions:
Answers:

You potentially can not prevent user from viewing the html source content. The site that you have listed prevents user from rightclick. but Fact is you can still do ctrl-U in firefox to view source !

Questions:
Answers:

View source is not disabled in my browser (Chrome).

But they have added a lot of blank lines to the source, so you have to scroll down to view it. Try to scroll down and you will see.

the disabled right click is possible with javascript, but dont do it. Its very irritating for the user.

Questions:
Answers:

Right click is disabled using JavaScript source is visible scroll down

Questions:
Answers:

This code is used for disable the right click events and keyboard short cuts.

Just try with this code

document.onkeydown = function(e) {
    if(e.keyCode == 123) {
     return false;
    }
    if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){
     return false;
    }
    if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){
     return false;
    }
    if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){
     return false;
    }

    if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)){
     return false;
    }      
 }

Questions:
Answers:

You cannot effectively hide your HTML and JavaScript code, even if you encrypt or minify it.

If the code you’re trying to hide is really sensitive, it should either be in a protected area of the site, i.e. an area that you can only access via a username and password, or potentially in a client application that isn’t exposed via the web.

If you have to expose the application functionality via a web frontend, you could use Silverlight to write the frontend or bits of the frontend. In the old days you could also use ActiveX.

Questions:
Answers:
<script>
$(document).ready(function() {
    document.onkeydown = function(e){
        if (e.ctrlKey &&
            (e.keyCode === 67 ||
                e.keyCode === 86 ||
                e.keyCode === 85 ||
                e.keyCode === 117)) {
            return false;
        } else {
            return true;
        }
    };
});
</script>

Questions:
Answers:

You can use JavaScript to disable the context menu (right-click), but it’s easily overwrittable. For example, in Firefox, go to Options -> Content and next to the “Enable JavaScript” check box, click Advanced. Uncheck the “Disable or replace context menus” option. Now you can right-click all you want.

A simple CTRL+U will view the source. That can never be disabled.

Questions:
Answers:
$(document).ready(function() { 
 `$(document).bind("contextmenu copy paste cut drag drop ",function(e {`return false;`});`

Questions:
Answers:

You can’t.

ANYTHING that can be read by the browser can also be read by humans. If you want something hidden, don’t send it to the user’s browser.

You can add all sorts of gimmicks and tricks to disable right-click and disable ctrl+U

All a user has to do is add view-source: to the url and they will see the source right away.

Example

view-source:https://stackoverflow.com