[Project_owners] Display right-click context menu programmatically

Todd Long longfocus at gmail.com
Sun Jul 8 20:38:32 PDT 2007


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);
  }
}

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

-- 
longfocus at gmail dot com
http://www.longfocus.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/project_owners/attachments/20070708/5e60e253/attachment.html 


More information about the Project_owners mailing list