我沒有得到足夠的睡眠或什麼?這下面的代碼爲什麼canvas.toDataURL()會引發安全異常?
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
沒有辦法,這不應該工作!任何人都可以解釋這一點嗎?
請參閱此處以獲取解決方案:[如何使用canvas.toDataURL()在Adobe AIR中獲取圖像的base64?](http://stackoverflow.com/q/3672332) – 2013-07-09 23:21:36
該解決方案似乎對於不使用Adobe AIR的用戶。 – ObscureRobot 2013-08-16 22:53:19