Solved

No right click for netscape 6.1

Posted on 2001-08-20
15
155 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
  • 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
 

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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 100 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now