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

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

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also