Forum Moderators: open
In the first instance, you're signaling your visitor he or she is not to be trusted.
In the second, you're challenging someone who might not have given a thought to prying itno your stuff to not only attempt to bypass your effort, but pass the site on to others as a "lol, let's rock this guy's 'security' just for grins and giggles."
Neither seems a good idea to me, but hey, it's your site.
Good luck to you if you find a way to go that route.
Anyway, you should be able to find something helpful if you do a site search on "disable right-click," "disable view source," or "protect source code"
Not that I can think of why you would want to do this. But that's none of my business ;)
It's for young school kids, teacher would like to put some reference material online,
however kids may just copy/paste. I'm using frames, so the navbar will be active within the top frame,
the page with the content is what I need to protect.
Some kids may find a way around it, however - most won't.
<html>
<body>
<script language="JavaScript">
<!--
stop=1;
function IE1(){
if(event.button==2){ }
}
// Mouse right-click stopped in Internet Explorer 4+
function IE2(){
if((event.keyCode==121 && event.shiftKey==true) ¦¦ event.keyCode==93){ }
}
// The use of Shift-F10 and the 'Context Menu' key stopped in Internet Explorer 4+
function IE3(){
event.cancelBubble=true;
event.returnValue=false;
}
// The famous mouse double-click getaround stopped in Internet Explorer 4+
function IE4(){
if(stop==1){
event.returnValue=false;
}
}
// Page content selection stopped in Internet Explorer 4+
function NN1(e){
if(e.which==3){return false;}
}
// Mouse right-clicks, Shift-F10, and the 'Context Menu' key stopped in Netscape 3+
function NN2(){
if(stop==1){
return false;
}
}
// Page content selection stopped in Netscape 3+if(document.layers){
window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=NN1;
window.onselectstart=NN2;
}
if(document.all){
document.onmousedown=IE1;
document.onkeydown=IE2;
document.oncontextmenu=IE3;
document.onselectstart=IE4;
}
//-->
</script>
<table width=450>
<tr>
<td>
<div align="justify">
<font size=5><b>No right-clicks or text copying!</b></font><br>
<br>
This script supposedly stops right-clicks and text selections in both Internet Explorer (version 4+) and Netscape (version <6). Try using the right mouse button, Shift-F10, and/or the Context Menu key. Also, try selecting any portion of this text. If the script works the way it is supposed to, you will only be able to select text in the form field below.</div>
</td>
</tr>
</table><br>
<form name="testform">
<input type="Text" value="You CAN select the text in this field" name="field" onfocus="stop=0;" onblur="stop=1;" size=50><br>
<input type="Text" value="You CAN NOT select the text in this field" name="field2" size=50><br>
<br>
<input type="Button" onclick="document.testform.field.select();" value="Select the text in the first field">
This button does not work<br>
<input type="Button" onclick="stop=0;document.testform.field.select();stop=1;" value="Select the text in the first field">
This button works<br>
</form>
</body>
</html>
And, you might want to make sure the link pointing to the page looks something like:
<a href="#" onclick="framename.location.href='blah.html'">Link text</a>
That way they can't open the link in a new window ;)