html2canvas.js截屏並上傳到後臺
阿新 • • 發佈:2018-08-15
html 上傳 int ren end clas rev fff base64
$("#example1").on("click",function(event){ if(confirm("是否上傳")){ event.preventDefault(); html2canvas($(".jiBMsg"), { crossDomain: true, xhrFields: {withCredentials: true}, allowTaint: true, taintTest: false, background:"#fff", useCORS:true, onrendered: function(canvas) { // alert("111"); canvas.id = "mycanvas"; var dataUrl = canvas.toDataURL("image/jpeg"); // $("body").append(‘<img src="‘+dataUrl+‘">‘); // var pos = dataUrl.indexOf("4")+2; // dataUrl = dataUrl.substring(pos, dataUrl.length - pos);//去掉Base64:開頭的標識字符 $.ajax({ type: "POST", url:url, async: false, data: { ‘data‘: dataUrl}, dataType: "text", success: function (data) { alert(data); }, error: function (err) { console.log(err); } }); } }) } })
html2canvas.js截屏並上傳到後臺