当前第2页 返回上一页
修改代码:
1 2 3 4 5 6 7 8 9 10 | 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》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » html5使用html2canvas实现浏览器截图