-1

I am unable to take screenshot of my frame

$(function() {     
    $(document).on("click","#btnSave",function(){
        html2canvas($("#widget"), {
            onrendered: function(canvas) {
                theCanvas = canvas;
                document.body.appendChild(canvas);
                $("#img-out").append(canvas);    
            }
        });    
}); 
    }); 

The first image is with the QR codeThis is with OR code

And the second image is when i am taking screenshot the QR code disappears

  • how are you taking screenshot? – Vinay Patil Jul 22 '19 at 06:02
  • On click of save button – Saad Shaikh Jul 22 '19 at 06:03
  • Seems like duplicate ticket https://stackoverflow.com/q/52869639/1483629 – Vinay Patil Jul 22 '19 at 06:27
  • With content loaded from a different origin, this would only be possible if that content was CORS-enabled to begin with. – misorude Jul 22 '19 at 07:14
  • Any other possible way to do it??because it is on the same domain@misorude – Saad Shaikh Jul 22 '19 at 07:23
  • I added header of CORS but it is still not working i added this on my constructor header('Access-Control-Allow-Origin:https://www.localhost/2019/tv/'); header('Access-Control-Allow-Credentials: true'); header('Access-Control-Max-Age: 604800'); header("Access-Control-Allow-Headers: Origin, Content-Type, Accept, Access-Control-Request-Method"); header("Access-Control-Allow-Methods: GET, POST");@misorude – Saad Shaikh Jul 22 '19 at 10:05

1 Answers1

0
Try This

      <div id="capture" style="padding: 10px; background: #f5da55">
        <h4 style="color: #000; ">Hello world!</h4>
      </div>
      <div id="click">Click To Capture</div> 

script code

        <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-beta4/html2canvas.min.js"></script>

        <script type="text/javascript">
           $('#click').click(function(){
             html2canvas(document.querySelector("#capture")).then(canvas => {
           document.body.appendChild(canvas)
          });
         });
        </script>
Ravi Makwana
  • 375
  • 1
  • 4
  • 12