javascript : 디버그를 위한 window.debug 함수

javascript : 디버그를 위한 window.debug 함수

window.debug = function() {
    var msg = “”;
    if (arguments.length > 0) {
        msg = arguments[0];
    }
 
    if (typeof (msg) != “string”) {
        alert(“데이터가 스트링 형태가 아닙니다.”);
        return false;
    }
 
    var viewWidth = 800;
    var viewHeight = 600;
    var viewTop = (window.screen.availHeight – viewHeight) / 2;
    var viewLeft = (window.screen.availWidth – viewWidth) / 2;
 
    var strOpenFeature = “width=” + viewWidth;
    strOpenFeature += “,height=” + viewHeight;
    strOpenFeature += “,left=” + viewLeft;
    strOpenFeature += “,top=” + viewTop;
    strOpenFeature += “,status=yes,resizable=yes,toolbar=no,menubar=no,location=no”;
 
    var childWinObj = window.open(“about:blank”, “_blank”, strOpenFeature);
 
    var oTextArea = childWinObj.document.createElement(“TEXTAREA”);
    oTextArea.style.width = “100%”;
    oTextArea.style.height = “100%”;
    oTextArea.value = msg;
 
    childWinObj.document.title = “DEBUG”;
    childWinObj.document.body.appendChild(oTextArea);
    childWinObj.document.body.style.padding = “0px”;
    childWinObj.document.body.style.margin = “0px”;
};