Tariq Aziz
Tariq Aziz

Reputation: 798

html2canvas OnRender failed because of cross domain images

I want a screenshot of the current page through html2canvas. However, the code displays "here" and then stops the second alert function is not triggering

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

In the firebug the following error appears:

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

I think its because the image is from another domain, but I did not find any solution.

Upvotes: 1

Views: 2715

Answers (1)

Liad Magen
Liad Magen

Reputation: 73

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

Upvotes: 3

Related Questions