Html2canvas Error: Unaccepted TypeError: undefined is not a function

I used the below code to create a screenshot of the grid on my page. The "GridBody" in the code below is a DOM object.

html2canvas(gridBody ,{
                   onrendered:function(canvas){
                      var img = canvas.toDataURL();
                      window.open(img);
                   }
                });

      

But this gives an error:

Uncaught TypeError: undefined is not a function (html2canvas.js: 2191) _html2canvas.Preload (html2canvas.js: 2191) (anonymous function)

line 2191 in html2canvas.js file:

domImages = element.getElementsByTagName('img'), // Fetch images of the present element only

      

This works great when I give 'document.body' instead of 'gridBody'.

Could you please help me why the error occurs?

Note. DOM gridBody function starts and ends

<div>

      

tags. I can share it, but this space prevents the entire DOM from being inserted here, and I don't see a way to attach the file.

+3


source to share


1 answer


I had this problem and found that it happened because the selector that was passed to html2canvas is empty. This resulted in the item not being an item.



+3


source







All Articles