I'd like to get an image of an URL provide by user.
I thought to make a fetch
or an AJAX request to get the HTML code and then convert it with HTML2CANVAS but it doesn't seem to be working.
This is what I tested directly in the console of Trello website, line per line:
function preview_ws(url) {
$.ajax({
url: 'https://cors-anywhere.herokuapp.com/' + url,
success: function(result) {
html = document.createElement("html");
html.innerHTML = result;
}
});
}
preview_ws("https://vuejs.org/v2/guide/components.html#Passing-Data-to-Child-Components-with-Props")
// many errors like GET https://trello.com/images/components.png 404
// the HTML seems to correspond (title is Vue.JS)
html2canvas(html).then(canvas => {
document.body.appendChild(canvas)
});
// then, I have errors:
Then I have errors:
Error while parsing the 'sandbox' attribute: 'allow-storage-access-by-user-activation' is an invalid sandbox flag.
Promise {<rejected>: "Unable to find element in cloned iframe"}
Uncaught (in promise) Unable to find element in cloned iframe
I also tried with:
html2canvas(html.querySelector("body")).then(canvas => {
document.body.appendChild(canvas)
});
So how can I make what I want? I' m reminding you I want something on the client-side.