2024年2月22日发(作者:)

//go ahead and download dataURLs right away if(String(x).match(/^data:[w+-]+[w+-]+[,;]/)){ return Blob ? // IE10 can't do a[download], only Blobs: Blob(d2b(x), fn) :

saver(x) ; // everyone else can save dataURLs un-processed }//end if dataURL passed?

try{

blob = x instanceof B ?

x :

new B([x], {type: m}) ; }catch(y){ if(BB){ b = new BB(); ([x]); blob = b(m); // the blob }

}

function d2b(u) { var p= (/[:;,]/), t= p[1], dec= p[2] == "base64" ? atob : decodeURIComponent, bin= dec(()), mx= , i= 0, uia= new Uint8Array(mx); for(i;i

function saver(url, winMode){

if ('download' in a) { //html5 A[download]

= url; ribute("download", fn); TML = ""; Child(a); setTimeout(function() { (); Child(a); if(winMode===true){setTimeout(function(){ ObjectURL();}, 250 );} }, 66); return true; }

//do iframe dataURL download (old ch+FF): var f = Element("iframe"); Child(f); if(!winMode){ // force a mime that will download: url="data:"+e(/^data:([w-+]+)/, u); }

= url; setTimeout(function(){ Child(f); }, 333);

}//end saver

if (Blob) { // IE10+ : (has Blob, but not a[download] or URL) return Blob(blob, fn); }

if(){ // simple fast and modern way using Blob and URL: saver(ObjectURL(blob), true); }else{ // handle non-Blob()+non-URL browsers: if(typeof blob === "string" || uctor===z ){ try{ return saver( "data:" + m + ";base64," + (blob) );

}catch(y){ return saver( "data:" + m + "," + encodeURIComponent(blob) );

} }

// Blob but not URL: fr=new FileReader(); =function(e){ saver();

}; DataURL(blob); }

return true;} /* end download() */