← Back to Page domain
Page.addScriptToEvaluateOnNewDocument
Evaluates given script in every frame upon creation (before loading frame's scripts).
Domain: Page
stable
Parameters
| Name | Type | Description |
source | string | |
worldName (optional) | string | If specified, creates an isolated world with the given name and evaluates given script in it.
This world name will be used as the ExecutionContextDescription::name when the corresponding
event is emitted. |
includeCommandLineAPI (optional) | boolean | Specifies whether command line API should be available to the script, defaults
to false. |
runImmediately (optional) | boolean | If true, runs the script immediately on existing execution contexts or worlds.
Default: false. |
Returns
| Name | Type | Description |
identifier | ScriptIdentifier | Identifier of the added script. |
Example Request
{
"id": 1,
"method": "Page.addScriptToEvaluateOnNewDocument",
"params": {
"source": "source-value"
}
}
Example Response
{
"id": 1,
"result": {
"identifier": "identifier-value"
}
}
Usage in Node.js
const result = await send('Page.addScriptToEvaluateOnNewDocument', {"source": "source-value"});
console.log(result);
// {"identifier": "identifier-value"}