runtime.getDocumentId()
Returns the document ID of any window global or frame element. See the Work with documentId article for more information.
Syntax
js
let documentId = browser.runtime.getDocumentId(
target // object
)
Parameters
target-
A WindowProxy or a browsing context container
element(iframe, frame, embed, or object) for the target frame.
Return value
Returns the document UUID of the target. Throws an error if the window or frame was unloaded.
Examples
This code gets the document IDs of the top-level frame and its child frames:
js
const documentId = browser.runtime.getDocumentId(window);
const frameDocumentId = browser.runtime.getDocumentId(
document.querySelector("iframe"),
);