의존 : html2canvas
함수 dataURLtoFile (dataurl, 파일명) { , dataurl.split 도착 = ( '')이었다 MIME 도착 = [0] .match (/ :.? (*) /) [1] BSTR = 셀 (도착 [1]), N = bstr.length, 새로운 Uint8Array u8arr = (N); (N -) {동안 u8arr [N] = bstr.charCodeAt (N); } ([u8arr, 파일명, {유형 : MIME}) 새로운 파일을 리턴; } // 사용 예 : takeScreenshot 함수 () { html2canvas (는 document.body, { allowTaint : 사실, foreignObjectRendering : 사실 }). 다음 (함수 (캔버스) { //document.body.appendChild(canvas); VAR dataurl canvas.toDataURL = (); 파일이었다 = dataURLtoFile (dataurl 'cap.png'); // var에 URL = window.URL.createObjectURL (파일); VAR A = document.createElement ( "A"); VAR URL = window.URL.createObjectURL (파일); VAR 파일 이름 = 'cap.png'; a.href = URL; a.download = 파일명; a.click (); window.URL.revokeObjectURL (URL); CONSOLE.LOG (URL); }); }