Coding Global Background
Coding Global

the onload doesn't read the script javascript.vanilla

Archiviert a day ago
5 Nachrichten
4 Mitglieder
Erstellt a month ago
Aktualisiert a day ago
In Discord öffnen
_
Andrew_Whiteingale
Script Kiddie!
function TakeScreenshot() { console.log("test1!"); let mainpicture = document.getElementById("test"); let snwidth = mainpicture.scrollWidth; let snheight = mainpicture.scrollHeight; let rawfather = mainpicture.innerHTML; let SVGscreenhack =
<svg xmlns="http://www.w3.org/2000/svg">
<foreignObject width=${snwidth} height=${snheight}>
<div xmlns="http://www.w3.org/1999/xhtml">
${rawfather}
</div>
</foreignObject>
</svg>
; let svgblob= new Blob([SVGscreenhack], { type: 'image/svg+xml;charset=utf-8' }); let svgURL = window.URL.createObjectURL(svgblob); let invc = document.createElement("img"); console.log("test1.5!"); invc.onload = function() //must delete canvas element or not make it if it exists { console.log("test2!"); console.log("test2!"); console.log("test2!"); canvas = document.createElement("canvas"); canvas.width = snwidth; canvas.height = snheight; console.log("test2!"); let ctx = canvas.getContext("2d"); ctx.drawImage(invc,0,0); console.log("test2!"); window.URL.revokeObjectURL(svgURL); console.log("test2!"); } invc.src = svgURL; console.log("test3!"); downloadimg = document.getElementById("imgdownload"); downloadimg.download = "test.png"; downloadimg.href = canvas.toDataURL("image/png"); console.log("test3!"); }



I am trying to make a function that uses the canvas svg hack but for some reason no matter what it can't read inside invc.onload = function() and then gives error on line downloadimg.href = canvas.toDataURL("image/png");

However I have diagnosed it vastly through possibiltiies and couldn't find culprit. I should mention that some variables have already been defined above the function, that changing width and length in the SVGscreenhack is not the issue, that the .onload property is not the issue either and that it does read everything but invc.onload brackets, it does change downloadimg.download correctly outside of this.

I am not quite
UnoRouter KI API

Antworten (4)