Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable right click without alert, in IE and NS?

Status
Not open for further replies.

reinholdj

Programmer
Jul 19, 1999
5
0
0
US
I am looking for a good way to disable the right click, that does not produce an alert - and that is cross browser. (We test in IE 5+, NS 6+, and Opera 5+).

We have an app that will pop up windows that allow users to chose from a set of options, then add those selections to the main page.

I would like to disable the right click so that noone can bookmark, view source, or go "back" - the popup page.

I know nothing is foolproof, but there will be little incentive to try since all that is on the popup page will be a text list and some check boxes....

All of the scripts I have found have something wrong. Like they either have an alert in IE, or they dont have an alert but they will not work in NS....

Any suggestions?
 
Ok once agian, everything you are trying hide is on the toolbar. If you must "hide" your code with no pop-ups just replace the alert with something else like:

if(document.history){} -Greg :-Q
 
Good luck on hiding youe source...unless your doing your page in Flash, its easy to get.
 
I understand that there are still ways to duplicate the actions of the right click menu.

(why do people always just say "don't bother"?)

I simply want to get rid of the right click menu, with no alerts. We want the pop-up as simple as possible for the users.

Thats all...
 
try this... I'm not sure if it works in netscape, but it's worth a shot...

*:->* Sunny


<script language=&quot;JavaScript1.2&quot;>
<!--

if (window.Event) // Only Netscape will have the CAPITAL E.
document.captureEvents(Event.MOUSEUP); // catch the mouse up event

function nocontextmenu() // this function only applies to IE4, ignored otherwise.
{
event.cancelBubble = true
event.returnValue = false;

return false;
}

function norightclick(e) // This function is used by all others
{
if (window.Event) // again, IE or NAV?
{
if (e.which == 2 || e.which == 3)
return false;
}
else
if (event.button == 2 || event.button == 3)
{
event.cancelBubble = true
event.returnValue = false;
return false;
}

}

document.oncontextmenu = nocontextmenu; // for IE5+
document.onmousedown = norightclick; // for all others
//-->
</script>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top