Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internet Explorer 11 #180

Open
mandarkamat opened this issue Sep 27, 2021 · 1 comment
Open

Internet Explorer 11 #180

mandarkamat opened this issue Sep 27, 2021 · 1 comment

Comments

@mandarkamat
Copy link

Hi ....Not able to view the WordCloud on IE 11.

@musecreation
Copy link

musecreation commented Nov 10, 2024

IE 11 doesn't support polyfills. You will need to include polyfill libraries.
`
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script>

<!-- Polyfill for Fetch API -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/fetch.umd.min.js"></script>

<!-- Polyfills for Array methods used in the code -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/array-includes-polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/polyfill.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/map.min.js"></script>

`
**Note these libraries may update with versions, so check for the latest before including!

Also, include a fallback script in case the polyfills fail. Such as....

`
if (!window.Promise) {
alert('Your browser does not support Promises. Some features may not work.');
// You can also provide a polyfill or degrade gracefully here
}

if (!window.fetch) {
alert('Your browser does not support Fetch API. Some features may not work.');
// Fallback to XMLHttpRequest (if necessary)
// Example of XMLHttpRequest fallback:
window.fetch = function(url, options) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open(options.method || 'GET', url);
for (var key in options.headers) {
xhr.setRequestHeader(key, options.headers[key]);
}
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
resolve({
text: function() { return xhr.responseText; }
});
} else {
reject('Request failed with status ' + xhr.status);
}
};
xhr.onerror = function() {
reject('Network error');
};
xhr.send(options.body || null);
});
};
}

if (!Array.prototype.map) {
alert('Your browser does not support Array.prototype.map. Some features may not work.');
// Optionally provide a custom polyfill or alternative behavior for map()
Array.prototype.map = function(callback, thisArg) {
var arr = this;
var result = [];
for (var i = 0; i < arr.length; i++) {
result.push(callback.call(thisArg, arr[i], i, arr));
}
return result;
};
}

if (!Array.prototype.find) {
alert('Your browser does not support Array.prototype.find. Some features may not work.');
// Fallback for .find() method
Array.prototype.find = function(callback, thisArg) {
var arr = this;
for (var i = 0; i < arr.length; i++) {
if (callback.call(thisArg, arr[i], i, arr)) {
return arr[i];
}
}
return undefined;
};
}

if (!Array.prototype.includes) {
alert('Your browser does not support Array.prototype.includes. Some features may not work.');
// Fallback for .includes() method
Array.prototype.includes = function(searchElement, fromIndex) {
return this.indexOf(searchElement, fromIndex) !== -1;
};
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants