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

right click hides code

Status
Not open for further replies.

williamsba

Programmer
Aug 3, 2000
57
US
I am trying to make it so that when the user right clicks on the page a message box, instead of the menu, pops up with a message. i want it so that nobody can steal my code. I know this is not that hard, but I am having trouble finding code for this. Any help on this subject will be helpful, thank you... [sig]<p>Brad Williams<br><a href=mailto:williamsba1@2fssg.usmc.mil>williamsba1@2fssg.usmc.mil</a><br><a href= FSSG Homepage</a><br> [/sig]
 
you are probably the Millionth person, and I have to be the one to tell you &quot;YOU CANNOT HIDE YOUR PLAIN HTML CODES!&quot; you might have to write a java applet, throw all your codes into that, or do serverside programming, the browser has to have your HTML script to even show the page, so anyone can get your code, they can eithe rright click, they can goto Edit...View Source, they can &quot;Save HTML Page as...&quot; they can get your code in several ways, and no browsers are the same. I am thinking someone should write a FAQ to answer to all those who want to &quot;Hide their code&quot;

also for those of you who want to continue asking this, search the forum for this topic, there are plenty of answers listed through out the site , maybe not the answers you are looking for, but it makes a pretty clear point. [sig]<p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
[/sig]
 

Yea kb244 is right, but we can still at least try to hide it. lol

<script language=&quot;JavaScript1.2&quot;>
if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu()
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
function norightclick(e)
{
if (window.Event)
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
}
document.oncontextmenu = nocontextmenu;
document.onmousedown = norightclick;
</script>

I didn't write that, some guy at javascripts.com who always posts his code there did, his TM line is &quot;Samba Says Roar&quot; he he.

perlkid [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top