我使用以下代码将图像从Amazon S3存储加载到Android WebView:
var img = new Image();
img.crossOrigin = 'Anonymous';
img.src = <my.s3.amazon/image.jpg>;
img.onload = function() {
var canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
var context = canvas.getContext("2d");
context.drawImage(img, 0, 0);
var result = canvas.toDataURL();
}
最后一行抛出SECURITY_ERR: DOM exception 18
。我知道这是由从外域加载的图像引起的。但是我该如何解决这个问题?