I know there is already a question on here with solutions for this but I have little understanding of javascript and I can't seem to figure out what they are saying to add in or where. The link to it is here: IExplorer: SCRIPT438: Object doesn't support property or method 'btoa'
Can someone explain to me what they are doing to make it work? Thanks.
I know there is already a question on here with solutions for this but I have little understanding of javascript and I can't seem to figure out what they are saying to add in or where. The link to it is here: IExplorer: SCRIPT438: Object doesn't support property or method 'btoa'
Can someone explain to me what they are doing to make it work? Thanks.
window.btoa
. That function doesn't exist in older versions of IE. Instead, you must include a separate JS file (in a <script>
tag) that adds the btoa
function to the window
object. Such a script is called a "shim" or "polyfill" that manually fills in some methods that aren't natively supported in certain browsers. The linked script there (github./davidchambers/Base64.js) is such a shim for btoa
.
– apsillers
Commented
Jan 30, 2014 at 17:15
Older browsers may not support Window.bota
, which is basically an oddly-named method to convert strings to base64 representations, as you probably know.
Making new functionality available in older browsers is called "polyfilling". Put the script base64.js
(download) or base64.min.js
(download) on your website (I'm going to assume you're using the latter, and putting it in the /js/vendor
directory), and reference it thusly (before you need to use Window.bota
):
<script src="/js/vendor/base64.min.js"></script>
If the browser is newer, this script won't do anything (i.e., it won't replace the existing Window.btoa
implementation). If the browser is older, it will now have the functionality.
If you want to avoid the additional HTTP request required to read base64.min.js
, you can use yepnope:
yepnope({
test: window.btoa && window.atob,
nope: '/js/vendor/base64.js',
callback: function () {
// `btoa` and `atob` are now safe to use
}
});
add this line on the header of your page, and it will be fixed
<meta http-equiv="X-UA-Compatible" content="IE=edge">