问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/17114236/html2canvas-onrender-failed-because-of-cross-domain-images