Invalid character error while using atob() method

前端 未结 2 1596
北恋
北恋 2021-01-14 07:17

I have read a question in stack overflow with this code work in IE 10 but not work in ie9,

but still i am facing issue on this.

var image = canvas.t         


        
2条回答
  •  醉话见心
    2021-01-14 07:54

    In case someone reachs this and the image = image.replace(/^[^,]+,/, ''); solution doesn't work for them, I got the same error calling atob function in IE11.

    In my case, the error was caused because the base64 string had a carriage return each 76 characters.

    This wasn't a problem for Chrome or Firefox, but IE11 produced the InvalidCharacterError.

    b64Data = b64Data.replace(/\r\n/g, ''); solved my problem.

提交回复
热议问题