Canvas Html5 Javascript Code Not Working, With Canvas.todataurl()
I've failed to get this code working: (function() { // Creates a new canvas element and appends it as a child // to the parent element, and returns the reference to //
Solution 1:
document.getElementsByTagName('canvas')
returns a NodeList
, not a single element. So use
functionhi(){
var canvas = document.getElementsByTagName('canvas')[0];
imageData = canvas ? canvas.toDataURL() : "could not find a <canvas> element";
document.getElementById("his").textContent = imageData;
}
Solution 2:
Image data URLs belong in image src
attributes. Images don't have innerHTML
.
Post a Comment for "Canvas Html5 Javascript Code Not Working, With Canvas.todataurl()"