Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Making Screenshot Script TypeError: Cannot read properties of null (reading 'cloneNode')

Whenever I press Download ScreenShot Button I get this error Uncaught (in promise) TypeError: Cannot read properties of null (reading 'cloneNode') at d (dom-to-image.min.js:2:1519) How do I fix this - HTML Code for understanding my problem - https://jsfiddle.net/m5gneoL7/

 <button id="dload_img">Download</button>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/dom-to-image/2.6.0/dom-to-image.min.js" integrity="sha512-01CJ9/g7e8cUmY0DFTMcUw/ikS799FHiOA0eyHsUWfOetgbx/t6oV4otQ5zXKQyIrQGTHSmRVPIgrgLcZi/WMA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
  <script src="http://cdn.jsdelivr.net/g/filesaver.js"></script>
  <script>
    $(document).ready(function() {
      $("#dload_img").click(function() {
        domtoimage.toBlob(document.getElementById('whole_page','')).then(function(blob){
          window.saveAs(blob, "output.png");
        });
      });
    });
  </script>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

In your HTML, change:

<div class="whole_page">

to:

<div id="whole_page">

Because you are using document.getElementById to find whole_page, it needs to be the id of the div. If you really wanted to find the div by a class, then change the javascript to:

document.getElementsByClassName('whole_page')[0]

([0] because it returns an array)

I tried your fiddle and that does solve the immediate problem, but that just uncovers other breakage.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!