Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Block access to web page source code 2

Status
Not open for further replies.

NWTrust

Technical User
Apr 2, 2002
68
0
0
GB
Right clicking on a web page normally gives one the option of viewing the source code of the page. I know it is possible to block this, but how? Can anyone help me with this, please?

 
Hello Bud,

Put the following in the Header of your site.

Code:
<script language="JavaScript">
<!--
/*
No rightclick script v.2.5
(c) 1998 barts1000
barts1000@aol.com
Don't delete this header!
*/

var message="Sorry, that function is disabled.\nThis Page Copyrighted and\nImages and Text protected!\nALL RIGHTS RESERVED"; 

// Don't edit below!

function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// --> 

</script>

This should stop people from Right-Clicking on your site to view your source... be aware though that blocking the source is not completely possible, there are so many ways that people can view it.

At the end of the day, a persons browser has to view the code to construct your page for display, if the browser can read it then your user can find a way.

A little convincer that i always used to use is put a reasonable blank space at the top of your code, then when somone views the source it just presents them with a blank notepad and they have to scroll down, i know it sounds simple but you'd be suprised how many people are fooled by it.

Rob
 
I remember one of the clients I did web design for telling me about the Javascript way to "protect" the web page source code and graphics. While he was on the phone looking at a page that had this, I showed him how to defeat this by pressing the enter key while continuing to hold the mouse button down. There are all sorts of tricks that newbies try, and think that work, but none of them really do, and anyone who's been playing with the Internet any length of time knows how to defeat those methods.

As well, what kind of "special" source code do you have that isn't freely available or well-known anyway? I can pretty much guarantee that anything someone new to writing web pages can come up with has been done several times already, and there's at least one freely available page somewhere on the Internet explaining exactly how to create this effect.

Lee
 
You can drag the page into frontpage and then use the html view to see the source of a page, so if frontpage can do it, I'm sure there are other more impressive ways of doing it.
 
Anyone who charges you for some web page source code protection scheme is ripping you off. That scheme listed by askari isn't that difficult to crack, even the "strong" encryption one.

Lee
 
There's one fullproof method, but usually people don't end up using it. It is: Do not publish your site on the internet.
 
NWTrust,

I'm interested to know what is so special about your source code that you don't want others to "steal" it?

Also, don't you find it very ironic that you're asking on a public help forum how to stop people looking at your code, when a lot of what we do here is help people learn by showing them code?

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Chris,
Thanks for the reminder about the FAQ!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
I would serious advise against blocking the right click of the mouse. The right click menu can contain accessibility options for the hard of sight viewers, such as magnify tools and text readers.

I order to hide the functionality of your site, not the source code, I would recommend you look into PHP and CSS. Only the bare bones will be shown in the HTML source code, and advanced users will only be able to view the layout properties of your CSS, therefore, protecting any functionality at the server.
 
NWtrust, Forget trying to hide your code. If you want to stop someone from stealing your "application" then just put in some calls to a server-side module so that any critical processing is done in a hidden way. Since your server-side code cannot be copied your whole application cannot be stolen or if it is it wont work properly.

Clive
 
Thanks everyone. I must confess that I had no intention of using a block - it's just that I came across a site which had access to the code blocked and I was curious as to how this was done!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top