-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!

4
  • Sure is, but it's a lot of work. There's a reason those tools are native. Good luck! Commented Sep 22, 2015 at 13:01
  • this is a tad too broad ;) SO is more about answering specific questions.. Q&A style! Commented Sep 22, 2015 at 13:02
  • @NiettheDarkAbsol: Actually, for a REPL, all you need is eval(). Being native doesn't help. Commented Sep 22, 2015 at 13:03
  • See here stackoverflow.com/a/16616794/2632619 stackoverflow.com/a/6604660/2632619 Commented Sep 22, 2015 at 13:05

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

4 Comments

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?
@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?
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.
@NiettheDarkAbsol I totally agree with you. But I was in a good mood, so that's why I "helped".

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.