Skip to content Skip to sidebar Skip to footer

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

function hi(){
    var canvas = document.getElementsByTagName('canvas')[0];
    imageData = canvas ? canvas.toDataURL() : "could not find a <canvas> element";
    document.getElementById("his").textContent = imageData;
}

Solution 2:


Post a Comment for "Canvas HTML5 JavaScript Code Not Working, With Canvas.toDataURL()"