本文介绍了如何测试浏览器是否支持< input capture />的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何测试当前的浏览器是否支持移动浏览器的功能以使用设备相机拍照?




How could I test if the current browser support the feature of mobile browsers to use the device camera to take a picture?

https://addpipe.com/html-media-capture-demo/

Capture is basically ignored in all desktop browsers: https://caniuse.com/#feat=html-media-capture

How could I detect if I can use capture (and that it won't show an open file dialog, but will actually open the picture application)?

解决方案

You can create an input element in JS and test for the capture property. It will be undefined if unsupported.

var el = document.createElement('input')
var supported = el.capture != undefined

console.log('capture supported: '+supported)

Here's what it looks like in the iOS simulator

这篇关于如何测试浏览器是否支持< input capture />的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 18:36