javascript - 如何让html2canvas捕抓超出滚动条的部分。
本文介绍了javascript - 如何让html2canvas捕抓超出滚动条的部分。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
设置了allowTaint : false没有效果,有网友提议先将要截图的部分拷贝到body下方进行隐藏然后再进行捕抓,想请教大神除此之外是否还有更简便的技巧呢?
解决方案
改下源码:
主要是让用户调用时能够自定义需要截取Dom对象的宽和高
return renderDocument(node.ownerDocument, options, node.ownerDocument.defaultView.innerWidth, node.ownerDocument.defaultView.innerHeight, 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;
});
改成
//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;
});
这篇关于javascript - 如何让html2canvas捕抓超出滚动条的部分。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文