Forum Moderators: open

Message Too Old, No Replies

Right-Click disable?

         

Scaleskin

6:59 pm on Feb 16, 2004 (gmt 0)

10+ Year Member



I am assuming this is javascript from reading it..

I was sent this script which should enable me to disable the mouse right-click function on my webpage
However the advice I was given was to add this script to the <body> section of my webpages HTML code.. I have tried it in several locations in the HTML but it doesnt work at all, in one case I got an error message...something about line12...any ideas how I can use this script?

<script language=JavaScript>
<!--

//Disable right click script III- By Renigade (renigade@mediaone.net)
//For full source code, visit [dynamicdrive.com...]

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers¦¦(document.getElementById&&!document.all)) {
if (e.which==2¦¦e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN)ocument.onmousedown=clickNS;}
else{document.onmouseup=clickNSocument.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false"
// -->
</script>

I know this wont actually prevent people from veiwing the source of my website etc. but I would like to learn how to implement this stuff anyway..

Thanks in advance
Scaleskin

Purple Martin

9:38 pm on Feb 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're missing a closing bracket on this line:

document.oncontextmenu=new Function("return false"

Make sure you didn't leave anything else off when you copy'n'pasted the code.

Scaleskin

10:29 pm on Feb 16, 2004 (gmt 0)

10+ Year Member



nah, thats how it was when sent to me....I will correct it and try again. Thanks.

Scaleskin.

Scaleskin

10:34 pm on Feb 16, 2004 (gmt 0)

10+ Year Member



no, still seems to be doing nothing. I have corrected and added the code to my webpage www.scaleskin.50megs.com and it still allows rightclick, although something does seem to appear to load fer a second when the menu opens... any ideas whats going on?

Purple Martin

11:03 pm on Feb 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looking more closely at it, there is code missing in the middle of at least two other lines.

Get back to whoever sent it to you, or just search the web for a different sample code. This one is broken!

Scaleskin

1:33 pm on Feb 18, 2004 (gmt 0)

10+ Year Member



Its OK....someone just sent me a single line of code which does the same thing and isnt causing all these problems.. Problem sorted now.

Thanks.