Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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