-
Notifications
You must be signed in to change notification settings - Fork 3
/
GoldfishLoadSafelyForIe.js
38 lines (31 loc) · 1.13 KB
/
GoldfishLoadSafelyForIe.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
This helper script will allow you to invoke Goldfish safely in IE.
Simply copy the built bundled JS file and paste it into your browser's console window (developer toolbar).
Once this has finished, copy the script below and paste it using the same approach.
*/
function addHeadResource(src, type, callback) {
var link = document.createElement(type === 'js' ? 'script' : 'link');
link.setAttribute(type === 'js' ? 'src' : 'href', src);
link.setAttribute(type === 'js' ? 'type' : 'rel', type === 'js' ? 'text/javascript' : 'stylesheet');
if (typeof callback !== 'undefined') {
link.onreadystatechange = function ( ) {
if (this.readyState == 'complete') {
callback();
}
};
link.onload = function ( ) {
callback();
};
}
document.getElementsByTagName('head')[0].appendChild(link);
}
(function() {
var ua = window.navigator.userAgent;
if (ua.indexOf('MSIE ') > -1 || ua.indexOf('Trident/') > -1 || ua.indexOf('Edge/') > -1) {
//IE Pollyfill
addHeadResource('https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser-polyfill.min.js', 'js', Goldfish.Create);
} else {
//not in ie
Goldfish.Create();
}
})();