html5使用html2canvas实现浏览器截图


当前第2页 返回上一页

修改代码:

1

2

3

4

5

6

7

8

9

10

//2016-02-18修改源码,解决BUG 对于部分不能截屏不能全屏添加自定义宽高的参数以支持

 var width = options.width != null ? options.width : node.ownerDocument.defaultView.innerWidth;

 var height = options.height != null ? options.height : node.ownerDocument.defaultView.innerHeight;

 return renderDocument(node.ownerDocument, options, width, height, index).then(function (canvas) {

     if (typeof(options.onrendered) === "function") {

         log("options.onrendered is deprecated, html2canvas returns a Promise containing the canvas");

         options.onrendered(canvas);

     }

     return canvas;

 });

主要是让用户调用时能够自定义需要截取Dom对象的宽和高,现在调用方式如下

1

2

3

4

5

6

7

8

9

10

11

12

$("#btn_screen").on("click", function () {              

    html2canvas($("#tbl_exception"), {

        height: $("#tbl_exception").outerHeight() + 20,

        onrendered: function (canvas) {

            var url = canvas.toDataURL();

            //以下代码为下载此图片功能

            var triggerDownload = $("<a>").attr("href", url).attr("download", getNowFormatDate()+"异常信息.png").appendTo("body");

            triggerDownload[0].click();

            triggerDownload.remove();

        }

    });

});

以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!

相关推荐:

html 基于 canvas 实现截图的介绍

HTML5实现留言和回复的页面样式

以上就是html5使用html2canvas实现浏览器截图的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

html2canvas把div保存高清图的方法代码

html2canvas把div保存图片高清图(图文教程)

html5使用html2canvas实现浏览器截图

html 基于 canvas 实现截图的介绍

如何利用html2canvas 将html代码转为图片

canvas与h5如何实现视频截图功能

更多相关阅读请进入《html2canvas》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...