html2canvas等待页面加载,html2canvas loading issue when saving the image
I am using the following code to save the content of div (image and text) as an image using html2canvas.$(function() {$("#save").click(function() {var flag = true;var imgpath = document.getElementById
I am using the following code to save the content of div (image and text) as an image using html2canvas.
$(function() {
$("#save").click(function() {
var flag = true;
var imgpath = document.getElementById('file').value;
if(imgpath.length == 0)
{
alert('Please select image file to upload.');
flag = false;
}
else
{
html2canvas($('.body740'), {
onrendered: function(canvas) {
theCanvas = canvas;
var url = canvas.toDataURL("image/png");
var br = document.createElement("br");
var center = document.createElement("center");
var newImg = document.createElement("img"); // create img tag
newImg.src = url;
$(".body740").hide();
$("#canvas").show(); //div where the final image is shown
document.getElementById("rsimg").src=url;
document.getElementById("rsa").href=url;
}
});
}
});
});
But, when I click the save image button, it takes a lot of time to generate the image. Why is it taking so much time to load? What is the issue?
更多推荐
所有评论(0)