HTML2Canvas does not render full div, only what is visible on screen?

前端 未结 10 1846
甜味超标
甜味超标 2020-12-13 04:02

I\'m trying to use HTML2Canvas to render the contents of a div. Here is the code:

var htmlSource = $(\'#potenzial-page\')[0];

$(\'#btn\').on(\"click\", fun         


        
10条回答
  •  情话喂你
    2020-12-13 04:25

    I used window.scrollTo()in my case and it worked for me.

    Below is a sample code

    $('#btn').on("click", function() { 
        window.scrollTo(0,0);     
        html2canvas(htmlSource).then(function(canvas) {
            var img = canvas.toDataURL();
            window.open(img);
        });
        window.scrollTo(0, document.body.scrollHeight || document.documentElement.scrollHeight);
    });
    

提交回复
热议问题