html2canvas error
by Onefunction
HTML
<script src="https://github.com/niklasvh/html2canvas/releases/download/v1.3.3/html2canvas.min.js"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<div class="ttable">
<div class="trow">
<div class="tcell t1">
</div>
<div class="tcell t2">
</div>
<div class="tcell t3">
</div>
</div>
<div class="trow">
<div class="tcell t4">
</div>
<div class="tcell t5">Some text
</div>
<div class="tcell t6">
</div>
</div>
<div class="trow">
<div class="tcell t7">
</div>
<div class="tcell t8">
</div>
<div class="tcell t9">
</div>
</div>
</div>
<div class='ttable-image'>
</div>
<button>
Gen
</button>
CSS
.ttable {
display: table;
width: 200px;
height: 200px;
}
.trow {
display: table-row;
}
.tcell {
display: table-cell;
width: 33%;
height: 33%;
background-size: 18px 18px;
}
.ttable-image {
position: absolute;
top: 5px;
left: 250px;
background-color: green;
width: 200px;
height: 200px;
}
.t1 {
background-image: url("https://i.ibb.co/hfsS3r0/tl.jpg");
background-position: bottom right;
background-repeat: no-repeat;
}
.t2 {
background-image: url("https://i.ibb.co/gWWcQ8K/t.jpg");
background-position: bottom center;
background-repeat: repeat-x;
}
.t3 {
background-image: url("https://i.ibb.co/F5Ww2Hr/tr.png");
background-position: bottom left;
background-repeat: no-repeat;
}
.t4 {
background-image: url("https://i.ibb.co/W2MXtkr/l.jpg");
background-position: center right;
background-repeat: repeat-y;
}
.t6 {
background-image: url("https://i.ibb.co/svL9wch/r.jpg");
background-position: center left;
background-repeat: repeat-y;
}
.t7 {
background-image: url("https://i.ibb.co/VWDLB1v/bl.jpg");
background-position: top right;
background-repeat: no-repeat;
}
.t8 {
background-image: url("https://i.ibb.co/vJhYnTS/b.jpg");
background-position: top center;
background-repeat: repeat-x;
}
.t9 {
background-image: url("https://i.ibb.co/SNJBcY5/br.jpg");
background-position: top left;
background-repeat: no-repeat;
}
.t5 {
background-color: #fdc800;
}
JavaScript
$("button").on("click", function() {
html2canvas(document.querySelector(".ttable"), {
scrollX: -window.scrollX,
scrollY: -window.scrollY,
backgroundColor: null,
allowTaint: true,
useCORS: true,
// logging: true,
}).then((generatedImage) => {
jQuery(".ttable-image").html(generatedImage);
});
})