Forum Moderators: open

Message Too Old, No Replies

Right click script -- not working in Netscape

         

judithem

12:35 pm on May 27, 2004 (gmt 0)

10+ Year Member



Hello, folks.

I found that the little unobtrusive copyright notice I put up for right hand click, on the pages with original photographs, only works in IE. In Netscape it's as if I never had the code on the page.

Is there a workaround to make a javascript pop up, pop up on Newscape Navigator, too?

If it'll help, I'm using in the head:
<STYLE>
#contextMenu {
position: absolute;
visibility: hidden;
width: 120px;
background-color: #9966ff;
layer-background-color: lightgrey;
border: 2px outset white;
}

.A:Menu {
color: black;
text-decoration: none;
cursor: default;
width: 100%
}

.A:MenuOn {
color: white;
text-decoration: none;
background-color: darkblue;
cursor: default;
width: 100%
}
</STYLE>

<SCRIPT>
var menu;
function showMenu (evt) {
if (document.all) {
document.all.contextMenu.style.pixelLeft = event.clientX;
document.all.contextMenu.style.pixelTop = event.clientY;
document.all.contextMenu.style.visibility = 'visible';
return false;
}
else if (document.layers) {
if (evt.which == 3) {
document.contextMenu.left = evt.x;
document.contextMenu.top = evt.y;
document.contextMenu.onmouseout =
function (evt) { this.visibility = 'hide'; };
document.contextMenu.visibility = 'show';
return false;
}
}
return true;
}
if (document.all)
document.oncontextmenu =showMenu;
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = showMenu;
}
</SCRIPT>

and i'm using in the top of the body:
<DIV ID="contextMenu"
ONMOUSEOUT="menu = this; this.tid = setTimeout
('menu.style.visibility = \'hidden\'', 20);"
ONMOUSEOVER="clearTimeout(this.tid);"
>
If interested in purchasing this copyrighted print<A HREF="contact.html";
CLASS="menu"
ONMOUSEOVER="this.className = 'menuOn'"
ONMOUSEOUT="this.className = 'menu';" >
please reach the artist</a> for sizing and&nbsp;price.

<BR>
<A HREF="http://<snip>.net"; CLASS="menu"
ONMOUSEOVER="this.className = 'menuOn'"
ONMOUSEOUT="this.className = 'menu';"
></A>
</DIV>

thanks for reading -- judithem

[edited by: BlobFisk at 3:43 pm (utc) on May 27, 2004]
[edit reason] The posting of URLs is against TOS here (even in code). [/edit]

wavebird23

8:52 pm on May 27, 2004 (gmt 0)

10+ Year Member



Most no right click scripts only work in IE. I would recommend putting this cross browser no right click script in your page:
______________________________________________________
<script language=JavaScript>
<!--
var message="Function Disabled!";

///////////////////////////////////
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>
______________________________________________________
Hope this script works out for you!

DrDoc

9:09 pm on May 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



cross browser

Umm, I think not ;)
It does nothing in Opera...

judithem

10:10 pm on May 27, 2004 (gmt 0)

10+ Year Member



Well, I'll be satisfied if I can have my no right click pop up box show up in IE and NS.

Please tell me, as I'm not fluent in Java:
Is that code meant for the header of the html file?
Only? Does it go in the body? The one I showed had a piece in each place.

A week ago in the header I had on an alarm notice of sorts under the right click, but all in all it felt way too rough for the viewer. I removed it in lieu of this one which is gentle and now I realize it isn't cross browser at all. So.

I would like to gently remind my visitors that right clicking might bring them in contact with the photographer who made the copyrighted photo they are looking at, thus dissuading them from thoughtlessly downloading the material.

What I liked about the code I presented here that unfortunately only works in IE, is that I can design my little box's style. I'd like that flexibility so I can personalize the page.

Can the script so thoughtfully provided in message two, be personalized?

Is there some other one that can?

My sincere thanks,

JudithEm

wavebird23

12:28 am on May 29, 2004 (gmt 0)

10+ Year Member



You should put these scripts in the body tags of the page. The below script will alert your visitors only when they right click. Again, it should be in the body tags.
______________________________________________________
<script language=JavaScript>
<!--
var message="WARNING! You may not download these images without the photographers permission";

///////////////////////////////////
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>
______________________________________________________
Best of luck with your site :)

dcrombie

11:19 am on May 29, 2004 (gmt 0)



Most Mac's don't have a right-mouse button so this kind of code is meaningless.

judithem

12:09 am on May 30, 2004 (gmt 0)

10+ Year Member



I'm clunking along, making a thousand mistakes along the way, as i'm re-learning web development (been gone from it for seven years).

[I haven't had a mac in ten years. I grew up on macs. I'm simply trying to please a client. We may end up getting a digimark watermark.]

Thanks for pasting the code, I'll check it out.

Can it be modified stylewise?

I'd prefer the flexibility of a cross-browser right click code with which I can determine the text style and colors too. Is that possible?