-6

So basically, like the Developer console - where you can see the outputs to the console via console.log etc....

I want to implement something like this so I can see this on the actual html page instead of having to open the Developer console.

Is there a way of doing this? Thanks!

apark
  • 3
  • 1
  • 5

1 Answers1

0

You could use a implementation of this SO answer like this: (note - This is the code from that answer. Only the part former(msg) gave me an error, so I left that part out)

console.log = function(msg){
    $("#mylog").append("<div>" + msg + "</div>");
}

window.onerror = function(message, url, linenumber) {
    console.log("JavaScript error: " + message + " on line " + 
                linenumber + " for " + url);
}
console.log("test");
console.log("test");
va

And the HTML

<div id="mylog"></div>

Working JSFiddle

Community
  • 1
  • 1
Mathlight
  • 6,436
  • 17
  • 62
  • 107
  • I use `console.dir` all the time. How would you implement this? Because right now it just throws, and that doesn't help. In fact that reminds me, can your console show error messages? – Niet the Dark Absol Sep 22 '15 at 13:06
  • @NiettheDarkAbsol I'm not quiet sure. (this is mostly out of my league). But I've updated my answer with a another SO answer, maybe that answer will answer your question? – Mathlight Sep 22 '15 at 13:15
  • Well I hate to be a downer, but if you're answering a question by copying in stuff from another answer, then that's kinda plagiarism and also a sign that you should be voting to close as a duplicate. Now, you don't have your close-vote permission yet, but you will, and whenever you're tempted to copy another answer into yours, consider close-voting as duplicate instead. – Niet the Dark Absol Sep 22 '15 at 13:19
  • @NiettheDarkAbsol I totally agree with you. But I was in a good mood, so that's why I "helped". – Mathlight Sep 22 '15 at 13:54