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

`input.fileDialogOpened` event

· 52CE 我爱测

The `input.fileDialogOpened` event of the `input` module fires when a file picker dialog opens in a context, for example when `click()` or `showPicker()` is called on an `<input type="file">` element.

The input.fileDialogOpened event of the input module fires when a file picker dialog opens in a context, for example when click() or showPicker() is called on an <input type="file"> element.

Event data

The params field in the event notification is an object with the following fields:

  • context
    • : A string that contains the ID of the context in which the file picker dialog was triggered. Context IDs are returned by commands such as browsingContext.getTree.
  • element
    • : An object containing the ID that uniquely identifies the <input type="file"> DOM element that triggered the file picker dialog. This field is included when the file picker dialog is opened by a file <input> element.
  • multiple
    • : A boolean that indicates whether the file picker dialog allows multiple file paths.
      • true: The file picker dialog accepts multiple files (the associated <input> element has the multiple attribute).
      • false: The file picker dialog accepts only a single file path.
  • userContext
    • : A string that contains the ID of the user context in which the file picker dialog was triggered.

Examples

Receiving an event when a file picker dialog opens

Assume you have a WebDriver BiDi connection, an active session, and a subscription to input.fileDialogOpened active.

Suppose your page has an <input type="file"> element that accepts a single file and your script calls click() on the <input>. The browser sends the following notification when the file picker dialog opens:

{
  "type": "event",
  "method": "input.fileDialogOpened",
  "params": {
    "context": "5f07e3ca-ecac-465e-b9ef-49000c196ecf",
    "element": {
      "sharedId": "3be28343-afd3-4dea-a2b6-a863fbbb80e1"
    },
    "multiple": false
  }
}

You can then call input.setFiles with the element.sharedId from the notification to simulate file upload.

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

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

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