html调用相机相册

<!DOCTYPE html>  
<html lang="en">  
  <head>  
      <meta charset="UTF-8">  
      <title>HTML5页面如何在手机端浏览器调用相机、相册功能</title>  
  </head>  
  <body>  

  <div>  
   <input type="file" accept="image/*" value="相机" capture="camera">  
   <input type="file" accept="video/*" value="录像"    capture="camcorder">  
   <input type="file" accept="audio/*" value="录音"    capture="microphone">  
  </div>  
    <script>
        判断ios,如果是ios就去掉capture属性.

       var file = document.querySelector('input');
    if (getIos()) {
        file.removeAttribute("capture");
    }
    function getIos() {
        var ua=navigator.userAgent.toLowerCase();
        if (ua.match(/iPhone\sOS/i) == "iphone os") {
            return true;
        } else {
            return false;
        }
    }
 </script>
  </body>  
  </html> 
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容