1、问题描述
如果不跨域的话,截图正常。
如果有跨域的图片,那么js报错,报错信息如下:
Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
2、代码
/**
* 截图
*/
function doScreenShot(){
html2canvas(document.body, {
onrendered: function(canvas) {
canvas.id = "mycanvas";
var image =canvas.toDataURL("image/png").replace("image/png","image/octet-stream");
window.location.href=image; // it will save locally
}
});
}
3、补充
看到官方(https://github.com/niklasvh/html2canvas)上面有介绍代理啥的,也没看明白怎么使用,好像还没有java方面的代理。有人能补充一下这方面的使用介绍么?
或者有其他的web页面截图方面的方法也可以介绍下,谢谢~
附:
html2canvas
1、官网
https://github.com/niklasvh/html2canvas
2、这个是别人发的提问帖子,问的同样的问题,提问的人说他问题已经解决了,我他妈楞是没看懂啊http://stackoverflow.com/questions/9825962/how-to-use-html2canvas-proxy