admin管理员组文章数量:1410697
I use html2canvas (from html2canvas.hertzen) to capture screenshot. I got this strange error like this: The code of my webpage is put on one host, say Host A. If my webpage contains an image on another host, say Host B, then I hit this error: Cross-origin image load denied by Cross-Origin Resource Sharing policy
However, the confusing part is that if Host B is facebook (my image is a direct link to facebook .jpg) then the error disappear.
My function
html2canvas([document.body], {
useCORS : true,
logging : true,
onrendered : function(canvas) {
document.body.appendChild(canvas);
var myImage = canvas.toDataURL("image/png");
window.open(myImage);
}
Anyone got a tip? Tks
solution
html2canvas([document.body], {
useCORS: true,
proxy: "Server",
onrendered : function(canvas) {
ListUCapture = canvas.toDataURL("image/png");
}
});
Server is server of node.js
I use html2canvas (from html2canvas.hertzen.) to capture screenshot. I got this strange error like this: The code of my webpage is put on one host, say Host A. If my webpage contains an image on another host, say Host B, then I hit this error: Cross-origin image load denied by Cross-Origin Resource Sharing policy
However, the confusing part is that if Host B is facebook (my image is a direct link to facebook https://fbcdn-profile-a.akamaihd/hprofile-ak-ash4/372701_100000684388457_1551561655_q.jpg) then the error disappear.
My function
html2canvas([document.body], {
useCORS : true,
logging : true,
onrendered : function(canvas) {
document.body.appendChild(canvas);
var myImage = canvas.toDataURL("image/png");
window.open(myImage);
}
Anyone got a tip? Tks
solution
html2canvas([document.body], {
useCORS: true,
proxy: "Server",
onrendered : function(canvas) {
ListUCapture = canvas.toDataURL("image/png");
}
});
Server is server of node.js
Share
Improve this question
edited Jul 8, 2014 at 11:31
HoangHieu
asked Aug 1, 2013 at 9:50
HoangHieuHoangHieu
2,8403 gold badges32 silver badges46 bronze badges
1 Answer
Reset to default 4If you wish to load cross-origin images to a canvas, you need to either serve the image with cross-origin headers or under the same origin. That image under Facebook is served with the following header option set:
Access-Control-Allow-Origin:*
Meaning, it can be cross-origin loaded with the useCORS
option. However, it would appear that your Host B isn't serving them with cross-origin headers set.
本文标签: javascriptCrossorigin image load denied by CrossOrigin Resource Sharing policyStack Overflow
版权声明:本文标题:javascript - Cross-origin image load denied by Cross-Origin Resource Sharing policy - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744216663a2595669.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论