I am using Html2canvas to take a screenshot of a div and display it in a new window. Here is my javascript function
function capture() {
html2canvas(document.getElementById('screenshot'), {
onrendered: function(canvas) {
var img = canvas.toDataURL("image/png");
window.open(img);
}}
);
}
The problem with this code is that it captures only half of the div, as shown in the following figure:

I changed the identifier of the element to be captured to a “table” so that I can only reduce the screen table. But it looks like the screenshot only takes up half the target div (in terms of height).

Now when I select the whole body:
function capture() {
html2canvas(document.body, {
onrendered: function(canvas) {
var img = canvas.toDataURL();
window.open(img);
}
});
The result is as follows:

source
share