PDA

View Full Version : No Right Click script keeps undoing itself!


angelbutt
11-28-2002, 11:00 AM
I hope this is the right place for this question, if not, I'm sorry. I'm new to this.

I've installed a *no right click* script to my web-log. I need this there in order to use the graphics I choose to use, it's in the artists rules. It worked fine for quite a while, but lately ANYTIME I make ANY change to my blog, it undoes itself. And I get an error message like:

A Runtime Error has occured.
Do you wish to debug?

Line: 407
Error: Expected ')'

This is what the no right click script looks like when I first install it:



<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Thank You For Visiting";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>




And this is what it looks like after only an hour or so:

<script language=JavaScript>
<!--

//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Thank You For Visiting";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&amp;amp;&amp;amp;!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&amp;amp;&amp;amp;!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")

// -->
</script>


It seems to chage for some reason. I know nothing about this kind of thing, but I can't figure out where all those litle amp;amp's come from? Can anyone give me any advice or help on this matter?? I really need this No Right Click in place, or I can't use the graphics I purchased. I know I've placed it in the right place (between <body> and </body>), because it will work for a while.

Christina:confused:

whammy
11-28-2002, 11:32 AM
What's happening is your ampersands are being converted to their HTML equivalent, presumably by whoever hosts the web log (actually their script is likely doing it).

One method you can use is to store that script in its own file (i.e. "norightclick.js") on your server:


//Disable right mouse click Script
//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive
//For full source code, visit http://www.dynamicdrive.com

var message="Thank You For Visiting";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("alert(message);return false")



and reference it like so:

<script type="text/javascript" src="http://www.yoursite.com/norightclick.js"></script>

You should be able to do this anywhere in the page, if I remember right... so you could put it in a blog entry (assuming that the blog doesn't alter script tags as well!).

But the best place for it would probably be in the <head> section of your page.

This is called an "external javascript library". See here for more information:

http://www.javascriptkit.com/javatutors/external.shtml

Hope this helps. :)

angelbutt
11-28-2002, 11:35 AM
Yes, I have access to the HTML code for my blog template. That is how I get the graphics and such in there, if that is what you are talking about.

I will look at that site you suggested and see what I can find. Like I said, I'm a dunce when it comes to HTML, but I'm learning and am not afraid to try.

Thanks!

Christina

whammy
11-28-2002, 11:37 AM
Hey I just updated my above post, as well. Hopefully that will make it a bit clearer. ;)

whammy
11-28-2002, 11:49 AM
P.S. I don't know if you're aware of this or not, (or the artist you purchased the pictures from), but 'no right click' scripts really only offer protection from people unfamiliar with web design, etc.

At the least, I would take out the alert(message) portions of the script and just use "return false;", if he/she insists on having a right-click script, so as to lessen the annoyance to your visitors... :rolleyes:

:)