Created
October 1, 2008 10:14
-
-
Save snaka/14060 to your computer and use it in GitHub Desktop.
debug log for javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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