Last active
December 6, 2018 03:16
-
-
Save pingyen/560c0d14c19a64a05c4211e222911ba4 to your computer and use it in GitHub Desktop.
Simple JavaScript console.log for Browsers without console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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