Debug window for Javascript

I wrote this short little function when I got tired of debugging JavaScript by using the alert() function. It pops up a new window and outputs whatever you send to the function along with the UTC date.

JavaScript:
  1. function logOutput(message)
  2.     {
  3.     debugWindow = window.open(, ‘dbgWindow’, ‘height=300,width=400′);
  4.     var newDate = new Date();
  5.     debugWindow.document.body.innerHTML += newDate.toUTCString() + “<br>\n + message + “<br><br>\n\n;
  6.     }

To send a message to the debug window just call

JavaScript:
  1. logOutput(‘This is my message’);

Got a suggestion for making debugging easier in JavaScript? Share it in the comments.

Question, Comments...

Do you have more questions. Please either leave a comment below or join us in our new forum.

Leave a Reply