SecurityError: The operation is insecure.

来源:互联网 发布:户型优化设计合同 编辑:程序博客网 时间:2024/05/30 02:26
ImageCropper.prototype.getCroppedImageData = function(width, height, mime)
{
    var output = document.createElement("canvas");
    output.width = width || this.cropWidth;
    output.height = height || this.cropHeight;
    output.getContext("2d").drawImage(this.imageCanvas, this.cropLeft, this.cropTop, this.cropViewWidth, this.cropViewHeight, 0, 0, output.width, output.height);
    
    var r =  output.toDataURL(mime || "image/jpeg");

    return r;


注意toDataURL在转换图片时候有同域要求,若非同域图片,就会出现SecurityError: The operation is insecure. 
错误。

SecurityError: The operation is insecure.  


解决方法:在跨域的服务器上header设置为允许跨域请求

access-control-allow-origin: *  access-control-allow-credentials: true
例如:在jsp页面加上response.setHeader("Access-Control-Allow-Origin", "*");时,
0 0
原创粉丝点击