草案
此页面不完整。

capture attribute specifies that, optionally, a new file should be captured, and which device should be used to capture that new media of a type defined by the accept 属性。 Values include user and environment . The capture attribute is supported on the file input type.

capture attribute takes as it's value a string that specifies which camera to use for capture of image or video data, if the accept attribute indicates that the input should be of one of those types.

描述
user The user-facing camera and/or microphone should be used.
environment The outward-facing camera and/or microphone should be used

Note: capture was previously a Boolean attribute which, if present, requested that the device's media capture device(s) such as camera or microphone be used instead of requesting a file input.


					

范例

When set on a file input type, operating systems with microphones and cameras will display a user interface allowing the selection from an existing file or the creating of a new one.

<p>
	<label for="soundFile">What does your voice sound like?:</label>
	<input type="file" id="soundFile" capture="user" accept="audio/*">
	</p>
	<p>
	<label for="videoFile">Upload a video:</label>
	<input type="file" id="videoFile" capture="environment" accept="video/*">
	</p>
	<p>
	<label for="imageFile">Upload a photo of yourself:</label>
	<input type="file" id="imageFile" capture="user" accept="image/*">
	</p>
					

Note these work better on mobile devices; if your device is a desktop computer, you'll likely get a typical file picker.

规范

规范 状态
HTML Media Capture
The definition of 'capture attribute' in that specification.
推荐

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

No compatibility data found. Please contribute data for "html.elements.attribute.capture" (depth: 1) to the MDN 兼容性数据存储库 .

另请参阅

元数据

  • 最后修改: