[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

Disable right-click menu without warning

I need a way to disable the showing of ie's or netscape's right-click menu when the user right-clicks. I need it so that it would also allow other showing when right-clicking.

The way I need it is that I got a script that pops a menu when someone right-clicks anywhere in the frame I definited. The problem is when right-clicking, the menu appears, but is hidden by the browser's right-click menu.

So I need a way to disable showing of the menu and only that, so my menu will show. The original script works wight left-click but this causes problems with links and personnaly I think it is better with right-click.
0
mannycalaveras
Asked:
mannycalaveras
  • 5
  • 5
  • 2
1 Solution
 
brigmarCommented:
It's my understanding that the only way IE will 'disable' the right click is by showing a javascript "alert() /  confirm() / prompt()" dialog.

I think you'll have to stick with the left click..

Brian
0
 
Michel PlungjanIT ExpertCommented:
Brigmar is correct. Only Netscape will allow cancelling of the right-click and that does not work on links or in form fields
IE has an activeX menu that WILL override the right click, but that would not work in netscape...

Michel
0
 
brigmarCommented:
Then I assume you _could_ combine the two... the IE activeX object with NS disable code inside (for a NS/IE disable).

Although... I think what is needed is for the click to then be passed to manny's own function.

Where's this activeX menu ?

Cheers,

Brian
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Michel PlungjanIT ExpertCommented:
Somewhere on msdn... I am sorry, but I do not have the url

Michel
0
 
larholmCommented:
<body oncontextmenu="return false">


/Thor
0
 
Michel PlungjanIT ExpertCommented:
THOR, GOD OF IE5-RIGHTCLICK!!!

Now make that work in IE4 and Netscape on links, formfields and images ;-)

Michel
0
 
larholmCommented:
hehe, god of thunder and now god of IE5-rightclick? cool ;)

In Netscape you don't have to display an alertbox to get it working, but you have to do this in ie 4 ;(

use the following:

<html>
<head>
<script language="Javascript">

function click(e) {
if (document.all) {
if (event.button == 2) {
alert(sorry);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
return false;
}
}
}


function cancelClick(){
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
if (!window.print){
document.onmousedown=click;
}
}

</script>
</head>
<body oncontextmenu="return false">

</body>
</html>

/Thor
0
 
Michel PlungjanIT ExpertCommented:
Yes, we know
Except the return false and the document.capturevents is ignored on links and form elements!

Michel
0
 
larholmCommented:
If you want it too on links, formfields and images, add these lines

document.images.onmousedown=click;
document.links.onmousedown=click;
if (window.all){
document.all.tags["INPUT"].onmousedown=click;
}

right after

document.onmousedown=click;

/Thor
0
 
larholmCommented:
response would be nice, I wrote this out of my head ;)

/Thor
0
 
Michel PlungjanIT ExpertCommented:
I will test this tomorrow!

Michel
0
 
larholmCommented:
Okay, but it should work correctly, even on links, images and form input fields ;)


However, IE 4 must have the alert box, but in my code I have disabled it if you're using NS 4 or IE 5.

/Thor
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now