7 replies
Is it possible to make the HTML source not viewable?
#html
  • Profile picture of the author webcosmo
    Hello,
    There is not real method or script, using that you can hide the html sources of your site. But your can do the following things:

    1. Develop the application using Flash and make it full screen and embedded the swf file in the web page.

    2. There are various scripts that will disable the right-click feature, preventing the user from saving images or viewing the source code. However, this will not protect the source code of your page. For example, Internet Explorer users may still click "View" and "Source" to view the source code of the page, or a user could disable scripts. Additionally, images can be stored by saving the web page to a hard drive.

    Thanks.
    {{ DiscussionBoard.errors[10570365].message }}
  • Profile picture of the author Lokki08
    In fact you can hide your source of HTML if you want by using jQuery like this:

    Using element class
    $('.elementClassName').hide();

    Using element id
    $('#elementId').hide();

    Or if you want to go even more advanced you can always use AngularJs, which has directive called ngIf or ngShow. Here's an example:

    <div ng-if="1 > 0" />

    That div will be displayed always because the expression is true always.
    {{ DiscussionBoard.errors[10570834].message }}
  • Profile picture of the author David Beroff
    Originally Posted by mercybadua View Post

    Is it possible to make the HTML source not viewable?
    No, but so what?
    Signature
    Put MY voice on YOUR video: AwesomeAmericanAudio.com
    {{ DiscussionBoard.errors[10571142].message }}
  • Profile picture of the author sayou20
    No, but it's possible to block the right click
    {{ DiscussionBoard.errors[10571158].message }}
  • Profile picture of the author justinrhensen123
    No but it is possible to Disable some functions
    {{ DiscussionBoard.errors[10576043].message }}
  • Profile picture of the author noah.whitmore
    As others have said here - there's no way to actually disable the user's ability to view the source code of your HTML. The browser has to download the source code in order to render the page to the user.

    It has been suggested that an alternative is to develop your site in flash. Personally, I wouldn't recommend this. A site completely developed in flash has disadvantages - chief among them being SEO considerations. Check out http://blog.woorank.com/2013/01/how-to-optimize-flash-for-seo/ for a pretty insightful article about that.

    It was also suggested that jQuery's .hide() method can be used - however, this will only hide the element in the view rendered by the browser. Effectively, this hides it from the users view - but it will not hide it in the source code.

    My Suggestion - Load the elements after page load using javascript

    Even though there's no way to disable the ability to view HTML source code, you can still take a few steps to make it more difficult for visitors to see the code.

    HTML will only be visible in the source code if it is actually in the code when the page loads. So, if there's a bit of HTML code that you would like to 'hide', you can load it into the page AFTER the page loads - just use some javascript.

    Here's your HTML
    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://code.jquery.com/jquery-1.11.3.js"></script>
      <title>Hiding Some HTML</title>
    </head>
    <body>
      
      <p>This will be visible when you view the source because it was in the source code when the page loaded.</p>
    
    <script src="path/to/script.js"></script>
    </body>
    </html>
    Here's the contents of script.js
    Code:
    (function($){
      $('p').after('<p>This will not be visible when you view the source because it was NOT in the source code when the page loaded - it was added with a script</p>');
    })(jQuery);
    Drawbacks? If the user views the source code, they will be able to load the script.js file in their browser as well - this will enable them to view the HTML that you inserted, even though it takes them an extra step.

    You could take it one step further and obfuscate the javascript using a tool like https://javascriptobfuscator.com/Jav...bfuscator.aspx - which basically converts many of the characters to ASCII codes. In this case, you don't even need to put the javascript in an external file. You could just post it right there on the page, since it's basically unreadable.

    Check out my demo here - https://jsbin.com/hefagu

    - Noah
    Signature
    No Pitch For The Moment - Just A Nice Hello.
    So... 'Hello'
    Feel free to PM me if you have any questions about my posts. I'd like to hear from you!
    {{ DiscussionBoard.errors[10602515].message }}

Trending Topics