解决IE10以下浏览器不能编码Base64字符的问题
一、问题描述 前几天发现写的js代码中用到的 window.btoa('mingwen'); 在IE10以下浏览器中报错,不支持此语法。 二、解决方法 要兼容IE9、IE8、IE7,我们可以专门针对这些浏览器再引入一段ployfill脚本或者一个JS文件即可。 也就是HTML中嵌入下面一段代码: <!--[if IE]> <script src="./base64-polyfill.js"></script> <![endif]--> base64-polyfill.js 内容: (function(f) { 'use strict'; /* istanbul ignore else */ if (typeof exports === 'object' && exports != null && typeof exports.nodeType !== 'number') { module.exports = f (); } else if (typeof define === 'function' && define.amd != null) { define ([], f); } else { var base64 = f (); var global = typeof self !== 'undefined' ? self : $.global; if