2022-07-05 13:41:43 +00:00
|
|
|
---
|
|
|
|
sidebar_label: Page.addScriptTag
|
|
|
|
---
|
|
|
|
|
|
|
|
# Page.addScriptTag() method
|
|
|
|
|
|
|
|
Adds a `<script>` tag into the page with the desired URL or content.
|
|
|
|
|
|
|
|
**Signature:**
|
|
|
|
|
|
|
|
```typescript
|
|
|
|
class Page {
|
|
|
|
addScriptTag(options: {
|
|
|
|
url?: string;
|
|
|
|
path?: string;
|
|
|
|
content?: string;
|
|
|
|
type?: string;
|
|
|
|
id?: string;
|
2022-07-06 07:05:37 +00:00
|
|
|
}): Promise<ElementHandle<HTMLScriptElement>>;
|
2022-07-05 13:41:43 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Parameters
|
|
|
|
|
|
|
|
| Parameter | Type | Description |
|
|
|
|
| --------- | ------------------------------------------------------------------------------ | ----------- |
|
|
|
|
| options | { url?: string; path?: string; content?: string; type?: string; id?: string; } | |
|
|
|
|
|
|
|
|
**Returns:**
|
|
|
|
|
2022-07-06 07:05:37 +00:00
|
|
|
Promise<[ElementHandle](./puppeteer.elementhandle.md)<HTMLScriptElement>>
|
2022-07-05 13:41:43 +00:00
|
|
|
|
|
|
|
Promise which resolves to the added tag when the script's onload fires or when the script content was injected into frame.
|
|
|
|
|
|
|
|
## Remarks
|
|
|
|
|
|
|
|
Shortcut for [page.mainFrame().addScriptTag(options)](./puppeteer.frame.addscripttag.md).
|