Skip to main content
Version: 23.2.0

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

范围

类型

描述

options

FrameAddScriptTagOptions

脚本的选项。

Returns:

Promise<ElementHandle<HTMLScriptElement>>

元素句柄 到注入的 <script> 元素。

¥An element handle to the injected <script> element.

备注

¥Remarks

page.mainFrame().addScriptTag(options) 的快捷方式。

¥Shortcut for page.mainFrame().addScriptTag(options).