How to take screen shot of current webpage using j

2019-01-06 20:18发布

I was trying to take screen shot of a web page using JavaScript/jquery.could you please explain me the code steps i need to follow.

thank you

标签: screenshot
1条回答
Summer. ? 凉城
2楼-- · 2019-01-06 20:38

The html2canvas2 JavaScript utility is suitable to take a screenshot of a webpage. You have to use three JavaScript libraries:

 1.jquery-1.10.2.min.js
 2.html2canvas.js
 3.jquery.plugin.html2canvas.js

Then call the function capture(), which will give you an HTML5 canvas-based screenshot in new window. It also generates a base64data value of image. It only works in browsers that support HTML5 canvas.

    <script type="text/javascript">
    function capture() {
            html2canvas($('body'),{
                onrendered: function (canvas) {                     
                            var imgString = canvas.toDataURL("image/png");
                            window.open(imgString);                  
            }
        });
   </script>
查看更多
登录 后发表回答