//保存到相册

 //保存到相册
 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);
}
posted @ 2020-07-03 13:18  威武的大萝卜  阅读(217)  评论(0编辑  收藏  举报