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

瀏覽器相容性

另見