How can I suppress the right-click menu?

This forum is for all Flare issues related to the HTML5, WebHelp, WebHelp Plus, and Adobe Air Targets
Post Reply
Sharon_G
Propeller Head
Posts: 59
Joined: Fri Oct 24, 2008 11:59 am
Location: Burlington, MA

How can I suppress the right-click menu?

Post by Sharon_G »

Hi Folks,
I have a breadcrumbs proxy on my Master Page that works very nicely, except that if you right-click on any active link in the breadcrumb trail you get the default browser menu. (The one that has "Add to Favorites", "Open", and "Save Target As" amongst other options that relate to the browser, not the Help window.) This also happens if you right-click on any related topics link.
I don't want the user to be able to see or use this menu and I'd like to know how (or if) I can suppress it.
Thanks so much in advance for your help.
Sharon
doc_guy
Propellus Maximus
Posts: 1979
Joined: Tue Nov 28, 2006 11:18 am
Location: Crossroads of the West
Contact:

Re: How can I suppress the right-click menu?

Post by doc_guy »

There are several javascripts you can add to your master page that will supress right-click options. However, be warned that they are easily circumventable and users who have javascript disabled will still be able to see the options. Plus, disabling right click can be very irritating to people who regularly use the options as they were intended.

That said, you can do a web search for "javascript right-click disable" to see several options. You would then add the javascript to your masterpage and be sure to select that masterpage in your target.
Paul Pehrson
My Blog

Image
Pete Lees
Sr. Propeller Head
Posts: 150
Joined: Thu Feb 09, 2006 12:33 pm
Location: Bracknell, Berkshire, UK

Re: How can I suppress the right-click menu?

Post by Pete Lees »

Hi, Sharon,

For what it's worth, this is the script that I use:

Code: Select all

<script type="text/javascript">
<!--

function right(e) {
   if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)) {
      return false;
   }
   else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
      alert("Function Prohibited");
      return false;
   }
   return true;
}

document.onmousedown=right;
if (document.layers) {
   window.captureEvents(Event.MOUSEDOWN);
}

window.onmousedown=right;

//-->
</script>
Pete
carolynmwallace
Sr. Propeller Head
Posts: 168
Joined: Thu Jan 31, 2008 12:21 pm
Location: Durham, NC

Re: How can I suppress the right-click menu?

Post by carolynmwallace »

This may be a silly question, but why would you want to do this? You're making more work for yourself with a solution that may or may not work (as other posters have pointed out above) and crippling a browser function that some users expect and use. And 9 times out of 10, the user doesn't right-click anyway.

Just wondering. Thanks!
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: How can I suppress the right-click menu?

Post by RamonS »

carolynmwallace wrote:This may be a silly question, but why would you want to do this? You're making more work for yourself with a solution that may or may not work (as other posters have pointed out above) and crippling a browser function that some users expect and use. And 9 times out of 10, the user doesn't right-click anyway.

Just wondering. Thanks!

I second that, there really is no good reason I know of to do this, but maybe there is one I do not know of....
Sharon_G
Propeller Head
Posts: 59
Joined: Fri Oct 24, 2008 11:59 am
Location: Burlington, MA

Re: How can I suppress the right-click menu?

Post by Sharon_G »

Hi folks,
Thanks for answering my question so quickly. Following Paul's suggestion I Googled for solutions and found that if you add the text
" oncontextmenu="return false;" to the body tag of the Master Page (and if you want to go the whole hog you can add it to the .htm files that control the Toolbar, Navigation, TOC etc.) you can disable the right-click context menu without displaying the alert, which is what I wanted to do.
Carolyn asked why I would want to do such a thing and it is a good question. The reason comes down to how we display the Help in our product. It is displayed in a custom window created by our friends in engineering. It only contains the Help toolbar and the Help navigation (no functionality indicating that this is, in fact, a browser window). The engineer who is designing this felt that, if the user used the right-click and saw browser commands that it would be confusing, especially since some of them reference unavailable browser functionality. For example; "Add to Favorites" used the browser favorites, not the WebHelp system favorites.
I agree that right-clicking is an unlikely scenario, but if the user never right-clicks, they will never know that the functionality is turned off. However, if the user does right-click, the chances are good that s/he will try to select something from the menu if it appears. If the menu is not available there is no risk of confusion.
I understand that there are users who may work with javascripts turned off, and in that case, all bets are off. I think we have done our best to avoid confusion, but this is the best we can do for now.
If I ever get feedback that the users find the lack of right-click functionality annoying, I'll let you know. Of course, that's after I pick myself up from the floor where I fell when I realized that someone had actually looked at the Help :wink:
Thanks again for pointing me in the right direction
Sharon...
Cynical, moi?
RamonS
Senior Propellus Maximus
Posts: 4293
Joined: Thu Feb 02, 2006 9:29 am
Location: The Electric City

Re: How can I suppress the right-click menu?

Post by RamonS »

I guess our concern was more down the line that most want to turn off the context menu to prevent copying information or going to a different URL. In your case disabling the context menu is plausible, since it is for optical / service reasons. And I get the impression as it is an honest attempt rather than having an entire business case rest on it.
carolynmwallace
Sr. Propeller Head
Posts: 168
Joined: Thu Jan 31, 2008 12:21 pm
Location: Durham, NC

Re: How can I suppress the right-click menu?

Post by carolynmwallace »

Thanks for the explanation, Sharon! It does make good sense for your situation.

In our case, users can still see the browser window, so I wouldn't use it. But I didn't know you COULD get rid of the browser "chrome," so I learned something! :-D
Sharon_G
Propeller Head
Posts: 59
Joined: Fri Oct 24, 2008 11:59 am
Location: Burlington, MA

Re: How can I suppress the right-click menu?

Post by Sharon_G »

Hi Carolyn, Ramon,
Thanks for confirming that my request was not totally off the wall :D
I'd attach screen shots of what our system looks like if I could figure out how to do it... It is really quite cool. The next version of our software is a total re-write so we are revamping everything, including migrating from HTML Help to WebHelp - and, of course, converting to Flare.
Lots of work - but lots of fun.
Sharon.
Carla
Propeller Head
Posts: 27
Joined: Fri Nov 12, 2010 7:10 pm
Location: Seattle, WA

Re: How can I suppress the right-click menu?

Post by Carla »

" oncontextmenu="return false;" to the body tag of the Master Page (and if you want to go the whole hog you can add it to the .htm files that control the Toolbar, Navigation, TOC etc.)

Hello, I realize that it has been a long time since this thread was active, but I'm hoping there is someone who can help me.

I successfully added the oncontextmenu statement to the body tag through the Master Page, but I want to disable right-clicking throughout my entire project. To disable it in the toolbar and other items mentioned above, can I go through the master page, or do I have to manually modify the associated HTM files each time I build the Help?

Thanks in advance.
i-tietz
Propellus Maximus
Posts: 1219
Joined: Wed Oct 24, 2007 4:13 am
Location: Fürth, Germany

Re: How can I suppress the right-click menu?

Post by i-tietz »

doc_guy wrote:... and users who have javascript disabled will still be able to see the options ...
*lol*
... ever looked at the source code of a help? Users who switch off javascript won't see a lot of the help anyway.
Inge____________________________
"I need input! - Have you got input?"
Post Reply