Screenshots with JavaScript

2017-06-05  本文已影响9人  RoyTien

Using the JavaScript library to capture the content on screen

Firstly, the html element will be converted into canvas.

<script src="./html2canvas.js"></script>
<script src="./html2canvas.svg.js"></script>

$('#btn').click(function(){
  html2canvas($('#img'), {
    onrendered: function(canvas) {
      var myImage = canvas.toDataURL("image/png");
      window.open(myImage);
      document.body.appendChild(canvas);
    },
    background: '#000000',
    allowTaint: true,
    useCORS: true
  });   
})
上一篇 下一篇

猜你喜欢

热点阅读