是我没睡够还是怎么的?下面这段代码
var frame=document.getElementById("viewer");
frame.width=100;
frame.height=100;
var ctx=frame.getContext("2d");
var img=new Image();
img.src="http://www.ansearch.com/images/interface/item/small/image.png"
img.onload=function() {
// draw image
ctx.drawImage(img, 0, 0)
// Here's where the error happens:
window.open(frame.toDataURL("image/png"));
}
抛出这个错误:
SECURITY_ERR: DOM Exception 18
这不可能行不通!有人能解释一下吗?
In the specs http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html它说:
每当 a 的 toDataURL() 方法
其 origin-clean 标志的画布元素
设置为 false 被调用时,该方法
必须引发 SECURITY_ERR 异常。
如果图像来自另一台服务器,我认为您不能使用 toDataURL()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)