Web Development

General discussion


Need help

By jacmari ·
Hello there...

I've seen it done on some web sites, and I wanted to do it on my own. How do I disable a View Source and a Save or Save As function on a web page?

Any help will be appreciated... thank you in advance.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -


by Yatin U In reply to Need help

<script language=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.oncontextmenu=new Function("return false")
// -->

Collapse -

One more thing..

by jacmari In reply to script

Thank you for the script.

Is there a way to disable Save As too??

Collapse -

it's useless!

by Anton Gombk?t? In reply to Need help

Sorry, you are looking for something impossible to do. A browser always loads the HTML and displays the page. That's what you want. What you do not want is to allow somebody to look at the code. But i need not use a browser to access the page. I candownload it with utilities like e.g. GetRight (http://www.getright.com) and can save the file. With CGI, you could check whether there is a browser's id given as "user agent", but i can fake this, too.
So you can't prevent users from looking at thecode. But you can prevent them from understanding the source.
The key to this is some kind of encryption. You encrypt the whole page via an algorithm and decrypt it with JavaScript and create the page in the browser. You can find various codes forthis on the internet. But once again - as you have to provide de decryption algorithm, a smart enough guy could still decrypt the code and look at your HTML source, so it's not worth the effort.
You don't tell us what you want to do, so i can't start guessing *why* you don't want to the code to be visible.

[when my english sounds funny, excuse me, i'm austrian]

Collapse -

Hidden code

by generalist In reply to it's useless!

If all you're trying to do is hide the HTML, then there are some doubts as to the usefulness of the tack.

On the other hand, hiding the JavaScript might be useful because that can be worth something.

Still, hiding it from "View Source" may nothide it from the cache. And if it is in the cache, you can view it. (IF you know about that little fact.)

Related Discussions

Related Forums