1

我想要通过 html2canvas 截取当前页面的截图。但是,代码显示“此处”,然后停止第二个警报功能未触发

alert("here");
html2canvas(instance.element, {
    onrendered: function(canvas) {
        alert("here");
        instance.options.onPostRender(canvas)

在萤火虫中出现以下错误:

"NetworkError: 404 Not Found - http://html2canvas.appspot.com/?url=https%3A%2F%2Fwww.otherdomain.com%2Flivezilla%2Fimage.php%3Fid%3D08&callback=html2canvas_1"

我认为这是因为图像来自另一个域,但我没有找到任何解决方案。

4

1 回答 1

3

I think you need a proxy in order to use cross-browser images. html2canvas allows you to use a proxy on it's settings:

html2canvas(instance.element, {
proxy: 'yourProxyPageOnTheSameServer.php',
onrendered: function(canvas) {
    alert("here");
    instance.options.onPostRender(canvas)

and there's a proxy in php here: https://github.com/brcontainer/html2canvas-php-proxy

于 2013-11-28T13:28:51.950 回答