大网数据广告活动
Web 标准与前端开发

`script.removePreloadScript` command

· 52CE 我爱测

The `script.removePreloadScript` command of the `script` module removes the specified preload script.

The script.removePreloadScript command of the script module removes the specified preload script.

Syntax

/* With required parameters */
{
  "method": "script.removePreloadScript",
  "params": {
    "script": "d4b1a0f6-2a3c-4f7d-9e21-5c6b7a8d9e0f"
  }
}

Parameters

The params field contains:

  • script
    • : A string that contains the UUID of the preload script to remove. Preload script IDs are returned by the script.addPreloadScript command.

Return value

The result field in the response is an empty object ({}).

Errors

  • invalid argument
    • : Thrown if a required parameter is missing or has an invalid type.
  • no such script
    • : Thrown if no preload script with the specified script ID is found.

Description

After a preload script is removed, the browser no longer runs it in new documents. Removing a preload script does not undo changes it has already made.

When a session ends, the browser automatically removes all preload scripts registered in that session.

Examples

Removing a preload script

Assume you have a WebDriver BiDi connection and an active session.

Suppose you registered a preload script that logs each new document's URL by using script.addPreloadScript. The browser returns the preload script's ID in the script field.

To stop logging URLs for new documents, send the following message to remove the preload script:

{
  "id": 3,
  "method": "script.removePreloadScript",
  "params": {
    "script": "d4b1a0f6-2a3c-4f7d-9e21-5c6b7a8d9e0f"
  }
}

The browser responds with an empty result object:

{
  "id": 3,
  "type": "success",
  "result": {}
}

When you subsequently navigate a context to a new document, the removed preload script no longer logs the document's URL.

Specifications

Browser compatibility

See also

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。