Path: blob/main/files/en-us/mozilla/add-ons/webextensions/api/runtime/getframeid/index.md
6552 views
------{{AddonSidebar}}
Returns the frame ID of any window global or frame element when called from a content script or extension page, including background pages.
Syntax
Parameters
target: A {{glossary("WindowProxy")}} or a {{glossary("browsing context")}} container Element (iframe, frame, embed, or object) for the target frame.
Return value
Returns the frame ID of the target frame, or -1 if the frame doesn't exist.
Examples
This code recursively walks descendant frames and gets parent frame IDs.
{{WebExtExamples}}
Browser compatibility
{{Compat}}
Note: Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.