Welcome to WebmasterWorld Guest from 54.147.189.54

Forum Moderators: open

Message Too Old, No Replies

Disabling Mouse

how to?

     
12:54 am on Feb 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 12, 2002
posts:1123
votes: 0


I would like to disable both right and left click of a mouse on a certain page?

How can I do this?

1:38 am on Feb 19, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 10, 2002
posts:68
votes: 0


There are methods to do this but people will always find a way to circumvent any protection mechanisms, so it is probably not advisable to do this.

Thanks.

1:41 am on Feb 19, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 8, 2001
posts:447
votes: 0


yep!
2:33 am on Feb 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


fasheze, what on earth are you up to here?
2:49 am on Feb 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Dec 2, 2002
posts:1167
votes: 0


Wouldn't that tactic be tantamount to a flashing neon sign that says "HEY, there's something on this page I'm not wanting you to know about?" or "Hey, just you try to copy my stuff, go ahead, I dare ya, cause you can't!"

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.

5:51 am on Feb 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


In any case, you will only be able to successfullly accomplish this in IE and NN, and this only as long as the user leaves JavaScript enabled.

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 ;)

7:27 am on Feb 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


Well, to be fair to fashezee, you can develop HTML applications for a "closed audience" (intranet, CD, etc.) that end up with very odd requirements -- things you would never think of doing on a general public web page.
1:02 pm on Feb 19, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:July 13, 2002
posts:133
votes: 0


Try www.slackerhtml.com/javascript/misc/norightorleft.html
... and have fun trying to copy the source code :-)
1:30 pm on Feb 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 12, 2002
posts:1123
votes: 0


All your concerns are understood, however the site is for a closed audience.

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.

7:55 pm on Feb 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


Then you might be interested in this little thingy. It will "prevent" not only right and left clicks, but also prevent selecting the text:

<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 ;)

8:05 pm on Feb 19, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Mar 12, 2002
posts:1123
votes: 0


Thanks!