HTML attribute: capture - HTML: HyperText Markup Language 编辑
Draft
This page is not complete.
The 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 /wiki/en-US/docs/Web/HTML/Attributes/accept
attribute. Values include user
and environment
. The capture attribute is supported on the file input type.
The capture
attribute takes as it's value a string that specifies which camera to use for capture of image or video data, if the /wiki/en-US/docs/Web/HTML/Attributes/accept attribute indicates that the input should be of one of those types.
Value | Description |
---|---|
| The user-facing camera and/or microphone should be used. |
| 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.
Examples
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" /wiki/en-US/docs/Web/HTML/Attributes/accept="audio/*">
</p>
<p>
<label for="videoFile">Upload a video:</label>
<input type="file" id="videoFile" capture="environment" /wiki/en-US/docs/Web/HTML/Attributes/accept="video/*">
</p>
<p>
<label for="imageFile">Upload a photo of yourself:</label>
<input type="file" id="imageFile" capture="user" /wiki/en-US/docs/Web/HTML/Attributes/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.
Specifications
Specification | Status |
---|---|
HTML Media Capture The definition of 'capture attribute' in that specification. | Recommendation |
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论