Page.addScriptTag() 方法
🌐 Page.addScriptTag() method
在页面中添加一个 <script> 标签,包含所需的 URL 或内容。
🌐 Adds a <script> tag into the page with the desired URL or content.
语法
🌐 Signature
class Page {
addScriptTag(
options: FrameAddScriptTagOptions,
): Promise<ElementHandle<HTMLScriptElement>>;
}
参数
🌐 Parameters
范围 🌐 Parameter | 类型 🌐 Type | 描述 🌐 Description |
|---|---|---|
options | 脚本的选项。 🌐 Options for the script. |
返回:
Promise<ElementHandle<HTMLScriptElement>>
对注入的 <script> 元素的 元素句柄。
🌐 An element handle to the injected <script> element.
附注
🌐 Remarks
page.mainFrame().addScriptTag(options) 的快捷方式。
🌐 Shortcut for page.mainFrame().addScriptTag(options).