Я хотел бы сохранить объект в window
. В настоящее время он работает на Chrome, Edge, Firefox, но не IE.
Мой код:
(function() {
'use strict';
var bottom = Object.create(null);
bottom = {};
bottom.tools = {};
bottom.tools.detectIEEdge = detectIEEdge;
function detectIEEdge() {
var ua = window.navigator.userAgent,
msie, trident, rv;
msie = ua.indexOf('MSIE ');
if (msie > 0) {
return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
}
trident = ua.indexOf('Trident/');
if (trident > 0) {
rv = ua.indexOf('rv:');
return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
}
return false;
}
window.bottom = bottom;
})();
И мой код в HTML:
<script>
console.log(window.bottom) // undefined
</script>