Wendigovo StackDump

Simple JavaScript logging

It is really simple. Create div with absolute position and unique id ("log" here). Log function wraps given text into new div and places into given div. Also it maintains maximum number of logged messages.

# JS:
function log(txt) {
    if (Eng.console == null) return;
    var cElm = document.getElementById("log");
    var elm = document.createElement("div");
    elm.innerHTML = txt;
    cElm.appendChild(elm);
    while (cElm.childNodes.length > 15) {
        cElm.removeChild(cElm.firstChild);
    }
}

# HTML:
<div id="log" style="position:absolute;top:0;right:0;width:15em;font-size:small;border:1px solid gray"></div>