Reputation: 23
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.
Upvotes: 1
Views: 6094
Reputation: 317
add this line on the header of your page, and it will be fixed
<meta http-equiv="X-UA-Compatible" content="IE=edge">
Upvotes: 1
Reputation: 27282
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
}
});
Upvotes: 4