Skip to content

Instantly share code, notes, and snippets.

@snaka
Created October 1, 2008 10:14
Show Gist options
  • Save snaka/14060 to your computer and use it in GitHub Desktop.
Save snaka/14060 to your computer and use it in GitHub Desktop.
debug log for javascript
/*
Debug log window
@see http://ajaxcookbook.org/javascript-debug-log/
Usage:
log("message");
*/
function log(message) {
if (!log.window_ || log.window_.closed) {
var win = window.open("", null, "width=700,height=200," +
"scrollbars=yes,resizable=yes,status=no," +
"location=no,menubar=no,toolbar=no");
if (!win) return;
var doc = win.document;
doc.write("<html><head><title>Debug Log</title></head>" +
"<body></body></html>");
doc.close();
log.window_ = win;
}
var logLine = log.window_.document.createElement("div");
logLine.style.borderBottom = "1px dashed gray";
logLine.appendChild(log.window_.document.createTextNode(message));
log.window_.document.body.appendChild(logLine);
logLine.scrollIntoView();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment