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:
-
function logOutput(message)
-
{
-
debugWindow = window.open(”, ‘dbgWindow’, ‘height=300,width=400′);
-
var newDate = new Date();
-
debugWindow.document.body.innerHTML += newDate.toUTCString() + “<br>\n“ + message + “<br><br>\n\n“;
-
}
To send a message to the debug window just call
JavaScript:
-
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.