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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling View Source 3

Status
Not open for further replies.
Javascript can easily fix that problem, however this only works if the user clicks the right-click button, but there are always other ways to veiw sources, like View --> Source for one...
But in any case use this:

<script language=JavaScript>
<!--
var message=&quot;Put you're message here.&quot;;
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>

Put this in the <head> tag of the HTML page and it'll do the trick in NS and IE...if you wanna use this on multiple pages, put this script in a new file, like righclick.js, and just call this file on all pages, this way if you have to modify the message, you only do it once and not on all the pages that this script resides on...
If you need more help, just ask...
Laterz...
I have not failed; I merely found 100,000 different ways of not succeding...
 
They are using a context menu there.
The View>Source option is still available. Search the forum you will find the many, many, many disscusions against trying to disable or trick the right click. DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Jenny,

The reason you can't view source with right click on that page is because you are trying to right click over an image. Move your mouse to the far right of the page, over HTML, and you'll get the view source option. Or, just select Source from the View menu. I viewed the source on that page, no problem.

There is no way to prevent a visitor from viewing HTML source. However here are a few tips that might prevent beginners from viewing source.

#1: Store JavaScript and CSS in external files. When the visitor views the HTML source, they won't see the code on that page. Now if they're smart, they will know that they can just type the source link into their browser address and download that external file. But it's better than nothing.

#2: I put about 200 blank lines at the top of every HTML document in my web app. It seems sort of ridiculous now because most people are aware of that &quot;trick&quot;. However, some are not and I must admit that it stumped me the first time I saw it. Some people place a line like this at the top of the HTML document followed by a hundred or so blank lines.

<!-- View Source Disabled -->

When someone clicks view source, they see that line then just blank white. Some will not think to scroll down a few hundred lines to get to the actual source.

Another option is to use another plug in software like Flash or something like that to create your websites.

These workarounds are getting stale these days, but they're the only ones I know of at this time.

TW
 
Hi!
Thanks for all the responses guys, they all helped a lot!

Jenny :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top