Cannot set property 'src' of null in JavaScript -


i'm in middle of changing existing javascript code exports images inside html document word document. new functionality going capture canvas data inside html, convert .png , export i'm getting 'cannot set property 'src' of null' when code reaches part:

        //capture canvas data         var canvasdata = markup.find('canvas');          var tempimage = new image();          ////array hold of images         var imagearray = array();         (var = 0; < canvasdata.length; i++) {             tempimage.src = canvasdata[i].todataurl("image/png");             imagearray[i] = tempimage;             tempimage = null;         } 

any appreciated!

as can see nullifying tempimage inside loop, after first iteration assigned null value, in next iteration you'll trying set src null. why getting error. take var tempimage = new image(); inside loop.

   (var = 0; < canvasdata.length; i++) {        var tempimage = new image();         tempimage.src = canvasdata[i].todataurl("image/png");         imagearray[i] = tempimage;         tempimage = null;     } 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -