繁体   English   中英

此时不允许对元素输入进行属性捕获

[英]Attribute capture not allowed on element input at this point

这行代码:

<input name="img" type="file" accept="image/*" capture="camera" onchange="uploadImage(this, 75)" />

未能通过W3C HTML5 验证器检查:

在此处输入图片说明 我很感激任何人告诉我为什么 W3C(和任何解决方案)的错误,因为代码工作正常并且它为移动设备打开了相机。

这是验证器中的一个错误。

到目前为止,即使capture属性还没有进入HTML 规范,它也已经具有“W3C 推荐”状态 ( HTML Media Capture )。 因此,它应该已包含在验证器中。

2018 年 3 月, W3C 邮件列表中提出了一个问题,验证者团队的一名成员承认了这一点。 它已于20203 月 21 日修复。

如果您想了解有关 HTML Media Capture 的正确语法的更多信息,请查看这篇文章

 label.cameraButton { display: inline-block; margin: 1em 0; /* Styles to make it look like a button */ padding: 0.5em; border: 2px solid #666; border-color: #EEE #CCC #CCC #EEE; background-color: #DDD; } /* Look like a clicked/depressed button */ label.cameraButton:active { border-color: #CCC #EEE #EEE #CCC; } /* This is the part that actually hides the 'Choose file' text box for camera inputs */ label.cameraButton input[accept*="camera"] { display: none; }
 <!DOCTYPE html> <html> <body> <label class="cameraButton">📷 <input type="file" accept="image/*;capture=camera"> </label> </body> </html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM