• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

No right click for netscape 6.1

Hi,

can you post a solution that will disable the right mouse button in netscape 6.1(not 6.01)?
I tried lots of scripts, most of them work for 6.0 but not for 6.1
I tried something like

if(document.getElementById && window.sidebar){// if NN6
document.onmousedown = disableRC;
document.onmouseup = disableRC;
}

function disableRC(x){
if(x.which==2||x.which==3){//if not left mouse button
// what to put here ???
}
}

the only thing that seems to work is self.close(), but this is too rude(BTW this closes the NN6.1 window when you right click without any prompts or whatever).
Please post only things you tested, not something you think will work(i tried tons of these)

Thanks

0
sphere301
Asked:
sphere301
  • 6
  • 5
  • 3
  • +1
1 Solution
 
avnerCommented:
var ie5 = (document.all && document.getElementById) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var n6 = (document.getElementById && !document.all) ? true : false;
var n4 = (document.layers) ? true : false;
if (ie5) {document.oncontextmenu = function(){return false}}
if (n6) {document.onmouseup = function(e) {if (e.button == 3) return false}}
if(n4) {window.captureEvents(Event.MOUSEDOWN);window.onmousedown =
function(e){if(e.target==document)return false;}}
if (ie4) { document.onmousedown = function(){return false}}
0
 
sphere301Author Commented:
Thanx avner, but did you really tested this with netscape 6.1?
Because it does not work for me, I can see the right click context menu with no problems :( in NN6.1
It works for IE 5.x & NN 4.x, but this is not what I'm interested in.

That's why I asked to post only tested (with NN 6.1) solutions.

Also please do not suggest scripts that use whatever kind of alert / prompt / confirm.
0
 
avnerCommented:
Dear sphere301 ,
I tested the code.
I tested iton NS6 and it works.
It seems like NS6.1 behaves diffrently.
Best regards,
         Avner.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
sphere301Author Commented:
Well what kind of NN6?
Is it 6.1 or 6.0x?
Because it does not work for my NN 6.1, which obviously behaves differently than any 6.0x in regard with this issue.
For your info, I use w2k pro / sp1 , if this matters, which I doubt.
0
 
avnerCommented:
I tested it on NS6.0
It seems like NS6.1 behaves diffrent then the NS6.0 .
I can suggest some options if you want , but I cannot test it because I do not have NS6.1  installed.
0
 
sphere301Author Commented:
Please post, something might work.
Although I think I tried evrything known so far , and simply nothing works .....
0
 
avnerCommented:
add to an onload method :

document.addEventListener(....onclick)

In the capturing function , test for a right click , and if it's a right click use :
event.preventDefault()

Should work..
0
 
webwomanCommented:
I turn off javascript (in any browser) and it's useless. I make a link to your page, right click on that (it's on MY page, remember, I can do whatever I want), choose SAVE AS and I have all your code, which I can then look at and modify to my heart's content.

Took all of... oh, maybe 5 seconds to overcome.

And you run the risk of alienating your users by implementing something that anybody who really wants the code (or graphic, or text) will be able to get past in seconds.

There ARE places where it is useful -- but they are few. If you're expecting this to 'protect' your code or graphics -- it ain't gonna do it. Better to put copyright notices on your pages and graphics, which at least allow you to sic lawyers on them when you see your stuff someplace.
0
 
avnerCommented:
webwoman ,
Sometimes you want to not allow right-click because you want to use the right click for the application you designed (for example right-column header for sorting) I belive this is the case.
0
 
webwomanCommented:
Quite possibly, and I did say that it had valid uses. But I wanted to make sure that they realized that it's not going to protect anything, and is easily bypassed.

You know how often this gets asked, and almost always it's being used to try to 'protect' code or images.
0
 
avnerCommented:
webwoman ,
I agree with the comment.. but..
I think there is something wrong in your point of view.... Just a weird feeling I have.

In general I prefer thinking that must of the users try to protect the right-click for internal usage and not to "protect" their code/images.

In fact I would go with emphasizing how right-click can be disabled and adding a short comment about the fact that this is useless if someone wants to overcome it , but not the other way around.

And again , this is just my opinion with all the respect to you.

-avner
0
 
Y_eeCommented:
this works in all browser

<html>
<head>
     <title></title>
    <script>
    var ie=Boolean(document.all);
    var ns4=Boolean(document.layers && !document.getElementById);
    var gecko=Boolean(!document.all && document.getElementById);
   
    function disableclick(e) {
        if (ns4) {
            if (e.which == 3) return false;
        } else if (gecko){
            if (e.button==2){
                e.cancelBubble=true;
                e.stopPropagation();
                e.preventDefault();
                return false;
            }
        }
    }
    if (ie) document.oncontextmenu=function() { return false; }
    else if (ns4){
        document.onmousedown=disableclick
        if (ns4) document.captureEvents(Event.MOUSEDOWN);
    } else {
        document.addEventListener('click',disableclick,false)
        document.addEventListener('dblclick',disableclick,false)
    }
    </script>
</head>
<body>
</body>
</html>


ciao
Y
0
 
sphere301Author Commented:
Y_ee ,

this really works for NN6.1, but not for 6.0
Could someone post something for all NN 6.xx
0
 
sphere301Author Commented:
Well, sorry for my last comment.
A asked something and recieved a working answer, so it's honest to accept it, which I do now.
Thank you, Y_ee.
I'll handle with NN6.0.
It's really annoying that something works in X.0 version, but no way in X.1.
As for all the comments like "Why you need this", "This can't help in xxx situation", etc - I know all that. But since I'm asking, I need to know it. I know very well that disabling the right button will not prevent almost anything, can annoy the visitors, and in general the overall effect might be negative.
So I think posting such comments is not the right attitude in most cases.
For me, I'm doing a site for a customer, he wants that, period(of course I also tried to explain this is nearly useless)
0
 
webwomanCommented:
If that's what they want, that's what they want. Not everybody listens to reason ;-)

Not everybody realizes that it doesn't do much (like your client). You might want to ask them to sign a statement that you've explained that it doesn't protect their copyright, doesn't provide any real protection to their content. Then, when somebody copies their graphics/words/etc. you can pull it out and remind them of that. ;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now