iTurki
iTurki

Reputation: 16398

Hiding HTML code from users?

I tried to hide a couple of element so that the end users can NOT see it when they see the page source. It seems NOT possible because this code will be downloaded and read by the browser. So, the user will find a way to read it.

However, I found some websites that hide part of the source! Take a look at this website: http://namechk.com/ . The source code related to the sites list is NOT there!! Is the code an HTML code? or it is something else that can be hided? And any one know a way to do this?

Thanks

Upvotes: 2

Views: 7467

Answers (5)

Pranay Rana
Pranay Rana

Reputation: 176896

The site is not showing the details because it is using Asp.net, JavaScript and jQuery to display data.

You can check it here: http://w3techs.com/sites/info/namechk.com

It is not possible to hide html from the client.

One thing you can do is remove unnecessary elements using JavasSript or jQuery.

Upvotes: 1

Jan Zyka
Jan Zyka

Reputation: 17898

It is because the page heavily relies on javascript. But you can (and your browser does) download the javascripts as well. If you dig into them you will find out how the page is generated.

You can obfuscate your javascript but I don't see much point in that. Do you think your HTML is so unique that somebody would steal it?

Upvotes: 5

Andy Davies
Andy Davies

Reputation: 1446

You could load code you want to be hidden into a div via an ajax call. The content of this div won't be seen in the browser source.

<script>
//ajax call via jQuery/Prototype loading content into div below
    $.ajax({
        url: "somepage.php",
        data: 'yourParameters'
        },
        success: function(data){
            $('#loadhtmlinviaAjax').show(); //toggle display status of this div as required
            $('#loadhtmlinviaAjax').html(data);
        }
    });
</script>

<div id="loadhtmlinviaAjax" style="display: none;"></div>

Upvotes: 0

Andrew Jackman
Andrew Jackman

Reputation: 13966

HTML can be hidden in an iFrame, pulling the source from another page (though they could view the source from there)

Upvotes: 0

Till
Till

Reputation: 3154

It is impossible to hide html code from the browser. Even in the link you posted the html code is there. It's just loaded dynamically. Have a look at the DOM in Firebug.

Upvotes: 4

Related Questions