This object is used by:

The code can be in a separate file, specified using file, or in a string, specified using code. One (and only one) of code or file must be set.

Be careful using the code parameter. Incorrect use of it may open your extension to cross-site scripting attacks.


Values of this type are objects. They contain the following properties:

boolean. If true, the code will be injected into all frames of the current page. If true and frameId is set, then the code will be injected into the specified frame and all its child frames. If it is false, code is only injected into the top frame. Defaults to false.
string. Code to inject, as a text string.
string. Path to a file containing the code to inject. In Firefox, relative URLs are resolved relative to the current page URL. In Chrome, these URLs are resolved relative to the add-on's base URL. To work cross-browser, you can specify the path as an absolute URL, starting at the add-on's root, like this: "/path/to/script.js".
integer. The frame where the code should be injected. Defaults to 0 (the top-level frame).
boolean. If true, the code will be injected into embedded "about:blank" and "about:srcdoc" frames if your add-on has access to their parent document. The code cannot be inserted in top-level about: frames. Defaults to false.
extensionTypes.RunAt. The soonest that the code will be injected into the tab. Defaults to "document_idle".

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic supportYesYes45.048.0No


This API is based on Chromium's chrome.extensionTypes API. This documentation is derived from extension_types.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: Alien426, Makyen, wbamberg, Jeremie, glukki, rolfedh
 Last updated by: Alien426,