It is said here that there are 3 types of document objects under window.

They are: HTMLDocument, XMLDocument, and XULDocument.

They say here that to get the context menu of the document we need to do:

var contextMenu = document.getElementById("contentAreaContextMenu");

If I did that in my webpage (off the Mozilla extension framework), it would return null since doesn't know anything about XUL or XUL context menus.

But inside my extension, it returns the context menu object.

But what if I need to access the HTML DOM from inside my extension? Which document object should I use? How do I get that?

有帮助吗?

解决方案

You can get to the current tab's HTML "document" with:

gBrowser.contentDocument

Source

Otherwise, if you are in the context of your extension, document will direct you to the XULDocument, which lets you select the XUL elements in the browser, and the ones that you added to the browser from your extension.

The contextmenu that you get from that command, is another xul element from the browser.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top