首页 > 其他 > 详细

//保存到相册

时间:2020-07-03 13:29:49      阅读:72      评论:0      收藏:0      [点我收藏+]
 //保存到相册
 function savePic(){   
     debugger      
    // var picurl= $("#picurl").attr("src");
      let picurl= window.sessionStorage.getItem(‘imgUrl‘);
    alert(  window.sessionStorage.getItem(‘imgUrl‘));
    savePicture(picurl);
}


var triggerEvent = "touchstart";
function savePicture(Url){
    debugger
    var blob=new Blob([‘‘], {type:‘application/octet-stream‘});
    var url = URL.createObjectURL(blob);
    var a = document.createElement(‘a‘);
    a.href = Url;
    a.download = Url.replace(/(.*\/)*([^.]+.*)/ig,"$2").split("?")[0];
    var e = document.createEvent(‘MouseEvents‘);
    e.initMouseEvent(‘click‘, true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
    a.dispatchEvent(e);
    URL.revokeObjectURL(url);
}
 //保存到相册
 function savePic(){   
     debugger      
    // var picurl= $("#picurl").attr("src");
      let picurl= window.sessionStorage.getItem(‘imgUrl‘);
    alert(  window.sessionStorage.getItem(‘imgUrl‘));
    savePicture(picurl);
}


var triggerEvent = "touchstart";
function savePicture(Url){
    debugger
    var blob=new Blob([‘‘], {type:‘application/octet-stream‘});
    var url = URL.createObjectURL(blob);
    var a = document.createElement(‘a‘);
    a.href = Url;
    a.download = Url.replace(/(.*\/)*([^.]+.*)/ig,"$2").split("?")[0];
    var e = document.createEvent(‘MouseEvents‘);
    e.initMouseEvent(‘click‘, true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
    a.dispatchEvent(e);
    URL.revokeObjectURL(url);
}

//保存到相册

原文:https://www.cnblogs.com/onesea/p/13229869.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!