Skip to content

Instantly share code, notes, and snippets.

@pingyen
Last active December 6, 2018 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pingyen/560c0d14c19a64a05c4211e222911ba4 to your computer and use it in GitHub Desktop.
Save pingyen/560c0d14c19a64a05c4211e222911ba4 to your computer and use it in GitHub Desktop.
Simple JavaScript console.log for Browsers without console
(function() {
var div = document.createElement('div');
div.style.cssText = [
'position: fixed',
'bottom: 10px',
'right: 10px',
'padding: 10px',
'background: yellow',
'z-index: 2147483647'
].join(';');
window.console = {
log: function(text) {
div.innerHTML += text + '<br />\n';
}
}
if (document.readyState !== 'loading') {
document.body.appendChild(div);
return;
}
document.addEventListener('DOMContentLoaded', function() {
document.body.appendChild(div);
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment