【问题标题】:html2canvas OnRender failed because of cross domain images由于跨域图像,html2canvas OnRender 失败
【发布时间】:2013-11-28 21:28:51
【问题描述】:

我想要通过 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"

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

【问题讨论】:

标签: php html html2canvas


【解决方案1】:

我认为您需要代理才能使用跨浏览器图像。 html2canvas 允许您在其设置上使用代理:

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

这里有一个 php 代理: https://github.com/brcontainer/html2canvas-php-proxy

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-11-08
    • 2016-04-17
    • 2023-02-11
    • 1970-01-01
    • 2010-11-07
    • 2010-11-07
    • 2014-01-15
    • 1970-01-01
    相关资源
    最近更新 更多