Can you keep someone from rightclicking your webpage and reading your source code?

beatmix01

Golden Member
Jun 22, 2001
1,008
1
0
<script>
<!--
/* Copyright http://www.perlscriptsjavascripts.com
Free and commercial Perl and JavaScripts */

isNN = document.layers ? 1 : 0;

function noContext(){return false;}

function noClick(e){
if(isNN){
if(e.which > 1) {return false;}
} else {
if(event.button > 1){return false;}
}
}

if(isNN){
document.captureEvents(Event.MOUSEDOWN);
}

document.oncontextmenu = noContext;
document.onmousedown = noClick;
document.onmouseup = noClick;

// -->
</script>
 

ProviaFan

Lifer
Mar 17, 2001
14,993
1
0
Haha, why even bother - there's so many ways to get around it, especially if you use Mozilla. ;)

But yes, it's "possible," if your audience is primarily IE-only.
 

Allio

Golden Member
Jul 9, 2002
1,904
28
91
You can block right-click if they're not using something like Proxomitron, but there's no way you can stop them from viewing the source, even in IE :p
 

Shawn

Lifer
Apr 20, 2003
32,236
53
91
Originally posted by: Pudgygiant
There's a few ways in javascript to stop right clicking, but it's easy to get around.

yep, they are worthless.
 

slydecix

Golden Member
Jul 16, 2001
1,898
0
0
Well if you're working with asp, then none of the important stuff shows up when they view the source
 

OREOSpeedwagon

Diamond Member
May 30, 2001
8,485
1
81
one way to get around it is first hold down the left button while you click the right button, then release the left button, then the right :)
 

ProviaFan

Lifer
Mar 17, 2001
14,993
1
0
Originally posted by: loki8481
don't be a hater ;) stealing code was how I taught myself java back in the stone age.
Hey, don't worry... people who put stupid right-click preventative crap on their pages usually don't have code worth stealing anyway. If you're going to steal code, steal some W3C-compliant XHTML or CSS, not some Frontpage-generated junk that someone thinks is so uber-l33t that it just absolutely must be protected. ;)
 

sonambulo

Diamond Member
Feb 22, 2004
4,777
1
0
doubleyoo tee eff?

i have scripts disabled in my ie, so my browser is bulletproof to that nonsense. i can right click whatever i want.