HTMLInputElement: capture property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{ApiRef("HTML DOM")}}
The **capture** property of the {{domxref("HTMLInputElement")}} interface reflects the {{HTMLElement("input")}} element's [capture](/en-US/docs/Web/HTML/Reference/Attributes/capture) attribute. Only relevant to the [<input> of type file](/en-US/docs/Web/HTML/Reference/Elements/input/file), the property and attribute specify whether, a new file should be captured from a user-facing (user) or outward facing (environment) camera or microphone. The type of file is defined the [accept](/en-US/docs/Web/HTML/Reference/Attributes/accept) attribute. If the attribute is not explicitly set, the capture property is an empty string.
Value
A string; generally either user or environment, or an empty string ("").
Example
const inputElement = document.querySelector("avatar");
console.log(inputElement.capture); // the current value of the capture attribute
inputElement.capture = "user"; // sets the capture valueSpecifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- {{domxref("HTMLInputElement.type")}}
- {{domxref("HTMLInputElement.multiple")}}
- {{domxref("HTMLInputElement.accept")}}
- {{domxref("HTMLInputElement.files")}}
- File type specifiers
- Using files from web applications
- File API