?
Solved

No right click for netscape 6.1

Posted on 2001-08-20
15
Medium Priority
?
181 Views
Last Modified: 2008-03-10
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
Comment
Question by:sphere301
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
  • 3
  • +1
15 Comments
 
LVL 14

Expert Comment

by:avner
ID: 6406209
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
 

Author Comment

by:sphere301
ID: 6406315
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
 
LVL 14

Expert Comment

by:avner
ID: 6406330
Dear sphere301 ,
I tested the code.
I tested iton NS6 and it works.
It seems like NS6.1 behaves diffrently.
Best regards,
         Avner.
0
Technology Partners: 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!

 

Author Comment

by:sphere301
ID: 6406379
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
 
LVL 14

Expert Comment

by:avner
ID: 6406416
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
 

Author Comment

by:sphere301
ID: 6406460
Please post, something might work.
Although I think I tried evrything known so far , and simply nothing works .....
0
 
LVL 14

Expert Comment

by:avner
ID: 6406491
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
 
LVL 19

Expert Comment

by:webwoman
ID: 6407174
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
 
LVL 14

Expert Comment

by:avner
ID: 6407239
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
 
LVL 19

Expert Comment

by:webwoman
ID: 6407386
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
 
LVL 14

Expert Comment

by:avner
ID: 6407402
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
 
LVL 1

Accepted Solution

by:
Y_ee earned 400 total points
ID: 6407524
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
 

Author Comment

by:sphere301
ID: 6410391
Y_ee ,

this really works for NN6.1, but not for 6.0
Could someone post something for all NN 6.xx
0
 

Author Comment

by:sphere301
ID: 6424599
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
 
LVL 19

Expert Comment

by:webwoman
ID: 6424631
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question