2016-05-16 6 views
1

Ich verwendete html2canvas Bibliothek. Ich möchte das Bild mit dem html2canvas speichern. I Erfolg, Bild von html2canvas zu speichern !!! BEEINDRUCKEND!!! aber .... IE hat versagt ... Ich möchte den gesamten Browser speichern.Javascript Saves Canvas (PNG) von IE

Ich finde navigator.msSaveBlob ... Ich war glücklich ~ aber das Glück dauerte nicht lange ... base64 Encording Image is String! aber ich möchte pngfile speichern! Hilf mir!!! (. PS Ich möchte ernsthaft eine starke Brust von IE schlagen)

~ dieser Code ~

html2canvas($("body")[0], { 
     onrendered: function(canvas) { 
     var img = canvas.toDataURL("image/png"); 
     var img2 = img.split("data:image/png;base64,")[1]; 



     //var blobObject = new Blob([img2],{type:"image/jpeg"}); 
     var blobObject = new Blob([img2]); 
     window.navigator.msSaveBlob(blobObject, 'test.png'); // The user only has the option of clicking the Save button. 
     alert('File save request made using msSaveBlob() - note the single "Save" button below.'); 
    } 
}); 

Antwort

0

Die traurige Antwort ist ...: - ((

Chrome & Firefox unterstützt haben canvas.toBlob für eine Weile, aber ...

IE & Rand noch nicht unterstützt nativ canvas.toBlob

Aber es gibt schöne Polyfills, die .toBlob zu IE/Edge bringen.

Ich mag Eli Grays FileSaverJS und sein canvas-toBlobJS.

BlueImp's JavaScript-Canvas-to-Blob ist auch populär.

+1

danke !!! Du bist so gut !! Ich beantworte die Frage von Ihrer Antwort ~ danke Ihnen danke –

+0

Gibt es ein Beispiel, um html2canvas zu konvertieren? – Hana90