Skip to content

Instantly share code, notes, and snippets.

@jairoFernandez
Last active August 30, 2017 03:55
Show Gist options
  • Save jairoFernandez/b173f4b5cd8701b7750f8c9b2b301d18 to your computer and use it in GitHub Desktop.
Save jairoFernandez/b173f4b5cd8701b7750f8c9b2b301d18 to your computer and use it in GitHub Desktop.
Console.log
(function () {
if (!console) {
console = {};
}
var old = console.log;
var logger = document.getElementById('log');
console.log = function (message) {
if (typeof message == 'object') {
logger.innerHTML += (JSON && JSON.stringify ? JSON.stringify(message) : String(message)) + '<br />';
} else {
logger.innerHTML += message + '<br />';
}
}
})();
<!DOCTYPE html>
<html>
<head>
<title>HTML5, CSS3 and JavaScript demo</title>
<style>
.lw { font-size: 20px; }
.terminal{
height: 800px;
color: #FFFFFF;
background-color: #000000;
padding: 10px;
border-radius: 5px;
font-size: 30px;
}
</style>
</head>
<body>
<!-- Start your code here -->
<div id="log" class="terminal"></div>
<!-- End your code here -->
<script>
// Reduce version, full versión in function.js
!function(){console||(console={});console.log;var o=document.getElementById("log");console.log=function(n){o.innerHTML+="object"==typeof n?(JSON&&JSON.stringify?JSON.stringify(n):String(n))+"<br />":n+"<br />"}}();
// Write JavaScript here
var prueba = "Hola mona";
console.log(prueba);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment