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.
LVL 1
mannycalaverasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.