HTMLInputElement: capture 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

HTMLInputElement 接口的 capture 属性反映了 <input> 元素的 capture 属性。该属性和属性仅与 <input type="file"> 相关,指定是应从用户面向的(user)还是面向外部的(environment)摄像头或麦克风捕获新文件。文件类型由 accept 属性定义。如果未显式设置该属性,则 capture 属性为空字符串("")。

一个字符串;通常为 userenvironment,或空字符串("")。

示例

js
const inputElement = document.querySelector("avatar");
console.log(inputElement.capture); // the current value of the capture attribute
inputElement.capture = "user"; // sets the capture value

规范

规范
HTML 媒体捕获
# dom-htmlinputelement-capture

浏览器兼容性

另见