How to use DOM element within client script in UI Builder
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2024 10:31 AM
Hi,
I am trying to run the below code within client script in UI Builder.
function handler({
api,
event,
helpers,
imports
}) {
helpers.timing.setTimeout(function() {
var script = this.document.createElement('script');
script.src='https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js';
script.onload = function() {
takeScreenshot();
};
this.document.head.appendChild(script);
});
function takeScreenshot() {
html2canvas(this.document.body, {
onrendered: function(canvas) {
var canvasVal = canvas.shadowRoot;
var dataURL = canvas.toDataURL("image/png");
var link = this.document.createElement("a");
link.href = dataURL;
link.download = "screenshot.png";
link.click();
}
});
}
}
I see an error message stating "html2canvas is not a function" in the browser log. Thanks.
15 REPLIES 15
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2024 07:26 AM