How to hide source page?

Hi, I have a question.
How can something that no one can see the source page?

The only way to stop people seeing the source code is not to publish it on your website. While there are ways to make it more difficult for people, they can’t stop people who are determined, and they will always have a negative impact on people using your site in one way or another.

Why does it matter if people can see your source code anyway?

You could minify it to make it harder to read, but as said, you can’t hide it in any practical way. If you think your code is unique, you are probably wrong anyway. :slight_smile:

There is no code that will block the source?
I want the code to be trying to lock this page:
view-source: siteadress

You answered the question yourself :slight_smile:

More info here.

This can Block This Page?

view-source:siteadress

Nope.

Besides being different for each browser (each browser has its own way of viewing a page’s source), your website itself would have no access to change browser settings.

Javascript can disable right clicks > view source > save as, ETC. The down side is people looking at your source usually know how to disabled JS from their browser.

Example: http://www.metaldetector.com/

Cant right click.

Disable Javascript and Viola. Source for the taking. =-)

This practice is highly discouraged, not to mention annoying. There are perfectly valid reasons to right click on websites (menu options for opening in a new tab, coping URLs, printing, translation, spelling, etc).

In any case, you can still get to the source even if right clicking is blocked by Javascript. (for example, in Chrome, click the menu button > tools > view source).

Not if you disable JavaScript or set your browser to disallow JavaScript interfering with the right mouse button.

The only part of the web page that is under the control of the site author is the content. The browser owner can override the CSS and JavaScript so the page displays and behaves how they want.

Hence why I stated "The down side is people looking at your source usually know how to disabled JS from their browser. "

But you don’t need to disable all of JavaScript to disable “no right click” scripts. Most browsers have an option in their settings that just disables JavaScript’s access to interfere with the context menu. You can have that permanently blocked and still allow JavaScript to run.

You could use a base64 encrypt for your pages, im sure people wont bother trying to decrypt it.

The browser would need to be able to decrypt it in order to be able to display the page - that would give people acess to the decrypted version simply by using a browser to decrypt it.

See http://javascriptexample.net/viewsource.php for how to get the decrypted source either using a simple bookmarklet or userscript in IE, Firefox, Chrome, Safari or Opera

I used Javascript on my website to prevent ctr + U function :



<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
document.onkeydown = function(e) {
        if (e.ctrlKey &&
            (e.keyCode === 67 ||
             e.keyCode === 86 ||
             e.keyCode === 85 ||
             e.keyCode === 117)) {
            return false;
        } else {
            return true;
        }
};
$(document).keypress("u",function(e) {
  if(e.ctrlKey)
  {
return false;
}
else
{
return true;
}
});
</script>


Hope it can help

A huge script just to attempt to turn off a couple of keypresses that can easily be turned back on. The biggest effect that script will have is to slow the loading of the page so that people don’t wait around for it to finish loading - unless they simple disable JavaScript for that page so as to not load the unnecessary script.

A suggestion to help improve your visitor’s experience of your site would be to get rid of that useless script.

Given that most people view the source code by right-clicking on the page to get the context menu up, or going through the menus, I would be surprised if your script even momentarily stopped more than a handful of people - not to mention the fact that you will then have annoyed them with your petty little script so they will be more determined to find a way round it (which really isn’t hard) and then potentially try to sabotage your site, exploit a weakness or just publicise how petty your site management is out of sheer devilment.

There really is NO reason to try to prevent people from accessing your source code. Really. You just can’t do it, and the hassle that you cause when you try isn’t worth it.

It is just as easy if not easier to press the contextMenu key on the keyboard to bring up the context menu as it is to right click with the mouse.

I think encryption is the best solution for this as above said. Its really worth.

WHY? What good does it do you? Absolutely none. It’s just selfish and arrogant.