码迷,mamicode.com
首页 > Web开发 > 详细

js剪切web网页成图片

时间:2017-04-11 09:21:38      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:type   name   val   new   uil   input   bsp   tee   har   

<html>
    <head>
        <meta name="layout" content="main">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script type="text/javascript" src="http://html2canvas.hertzen.com/build/html2canvas.js"></script>
        
        <script  type="text/javascript" >
        $(document).ready( function(){
                $(".example1").on("click", function(event) {
                        event.preventDefault();
                        html2canvas(document.body, {
                        allowTaint: true,
                        taintTest: false,
                        onrendered: function(canvas) {
                            canvas.id = "mycanvas";
                            //document.body.appendChild(canvas);
                            //生成base64图片数据
                            var dataUrl = canvas.toDataURL();
                            var newImg = document.createElement("img");
                            newImg.src =  dataUrl;
                            document.body.appendChild(newImg);
                        }
                    });
                });
            
        });
        
        </script>
    </head>
    <body>
        
        Hello!
        <div class="" style="">
            计算机天堂测试html5页面截图
            <br>jsjtt.com
        </div>
        
        <textArea id="textArea" col="20" rows="10" ></textArea>
        <input class="example1" type="button" value="button">
        生成界面如下:
    </body>
</html>

js剪切web网页成图片

标签:type   name   val   new   uil   input   bsp   tee   har   

原文地址:http://www.cnblogs.com/duguangyan/p/6691949.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!