[Project_owners] Display right-click context menu programmatically

Michael Vincent van Rantwijk, MultiZilla mv_van_rantwijk at yahoo.com
Mon Jul 9 01:22:44 PDT 2007


Todd Long wrote:
> Hey All,
> 
> I'm having trouble trying to display the right-click context menu
> programmatically (without having to actually right-click). I continue to 
> get
> an exception (see below) that I can't seem to get around and was hoping
> someone else might have a better idea/solution. What I've done is setup a
> window event listener for "click" that executes my code below. I'm checking
> for the left mouse button before attempting to show the right-click context
> menu (popup). Any suggestions/help would be great. Thanks.
> 
> Code
> window.addEventListener("click", doitfunc, false);
> 
> function doitfunc(aEvent) {
>  if (aEvent.button == 0) {
>    var context = document.getElementById("contentAreaContextMenu");
>    context.showPopup(document.documentElement, 0, 0, "popup", null, null);
>  }
> }

0, 0?  have you tried to change it (because it must be in the browser area).

> Exception
> Error: [Exception... "Component returned failure code: 0x8000ffff
> (NS_ERROR_UNEXPECTED)
> [nsIDOMXULDocument_MOZILLA_1_8_BRANCH.popupRangeParent]"  nsresult:
> "0x8000ffff (NS_ERROR_UNEXPECTED)"  location: "JS frame ::
> chrome://browser/content/browser.js :: anonymous :: line 3932"  data: no]
> Source File: chrome://browser/content/browser.js
> Line: 3932
> 
> I'm using Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4)
> Gecko/20070515 Firefox/2.0.0.4
> 




More information about the Project_owners mailing list