Skip to content

Instantly share code, notes, and snippets.

@dvdrtrgn
Last active August 29, 2015 14:14
Show Gist options
  • Save dvdrtrgn/4a20f61e7eed96cd905d to your computer and use it in GitHub Desktop.
Save dvdrtrgn/4a20f61e7eed96cd905d to your computer and use it in GitHub Desktop.
old IE fixer
Date.now = Date.now || function () {
return +new Date();
};
W.addEventListener = W.addEventListener || function (nom, fn) {
W.attachEvent('on' + nom, fn);
};
var i, W = window, C = (W.console || {
log: function () {}
});
if (window.window !== window) {
W = W.window;
C.all = 'log info error warn'.split(' '); // supplant these
for (i = 0; i < C.all.length; i++)(function (key) {
C[key] = (typeof C[key] === 'function') ? C[key] : function () {
if (C[key]) C[key](Array.prototype.slice.call(arguments).join(', '));
}; // close over the itr key function ref
}(C.all[i]));
C.all = 'assert clear count debug dir dirxml ' + // alias the rest
' exception group groupCollapsed groupEnd markTimeline ' + //
' profile profileEnd time timeEnd trace'.split(' ');
for (i = 0; i < C.all.length; i++)(function (key) {
C[key] = function () {
C.warn(Array.prototype.slice.call(arguments).join(', ') + '<' + key);
}; // close over the itr key
}(C.all[i]));
C.debug('IE8', 'Slippery window,', 'Dippy console');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment