zoukankan      html  css  js  c++  java
  • JS中调用android和ios系统手机打开相机并可选择相册功能

    编写不易,如有转载,请声明出处: 梦回河口:http://blog.csdn.net/zxc514257857/article/details/57626154

    实现android手机打开相机选择相册功能:

    <input class="js_upFile cover1" type="file" name="cover" accept="image/*" capture="camera" multiple/>
    

      

      这段代码在ios手机上只能打开相机,不能选择相册

    实现苹果手机打开相册及打开相机功能:

    <input class="js_upFile cover1" type="file" name="cover"/>
    

      这段代码在android手机上只能选择相册,不能打开相机

    兼容实现

    实现android手机打开相册及打开相机功能:

    <input class="js_upFile cover1" type="file" name="cover" accept="image/*" capture="camera" multiple/>
    

      对手机系统类型进行判断:

    $(function () {
        //获取浏览器的userAgent,并转化为小写
        var ua = navigator.userAgent.toLowerCase();
        //判断是否是苹果手机,是则是true
        var isIos = (ua.indexOf('iphone') != -1) || (ua.indexOf('ipad') != -1);
        if (isIos) {
            $("input:file").removeAttr("capture");
        };
    })
    

      

  • 相关阅读:
    touchMove VS touchCancel
    svg viewbox 作用
    reactjs reactLink
    放开linux下的端口
    运算符重载函数作为类成员函数和友元函数 (转)
    MBean和MXBean 区别
    transfer-encoding
    CSRF
    vue知识拓展
    居中
  • 原文地址:https://www.cnblogs.com/liaoyanglong/p/7833446.html
Copyright © 2011-2022 走看看