Search code examples
popupinternet-explorer-11es6-promisepolyfillsdivi

'Promise' is undefined in IE11


I have used this plugin to create popups in the Divi website I have built: https://wordpress.org/plugins/popups-for-divi/

The popups were not opening in IE because of the padStart() function and I found an alternative to replace the padStart() function using this code:

< script >

if (!String.prototype.padStart) {
    String.prototype.padStart = function padStart(targetLength, padString) {
        targetLength = targetLength >> 0; //truncate if number or convert non-number to 0;
        padString = String((typeof padString !== 'undefined' ? padString : ' '));
        if (this.length > targetLength) {
            return String(this);
        } else {
            targetLength = targetLength - this.length;
            if (targetLength > padString.length) {
                padString += padString.repeat(targetLength / padString.length); //append to original to ensure we are longer than needed
            }
            return padString.slice(0, targetLength) + String(this);
        }
    };
} <
/script>

Now the problem is, the popups are loading fine on Homepage but not on other pages and I am getting this error:

'Promise' is undefined

Can anyone help me get this problem resolved? This is the link to the website to check: https://site2.stagging.tk/

Thanks


Solution

  • I was able to resolve this problem by adding these two lines of code in the Header:

    <script src="https://unpkg.com/es6-promise/dist/es6-promise.auto.min.js"></script>
    <script src="https://unpkg.com/unfetch/polyfill/index.js"></script>

    Thanks