绿豆.Net

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

代码实现动态添加控件元素

// 标题栏文字
    var titleLabel = document.createElement("div");
    titleLabel.style.height = "14px";
    titleLabel.style.width = "200px";
    titleLabel.style.fontSize = "11px";
    titleLabel.style.color = "#ffffff";
    titleLabel.style.styleFloat = titleLabel.style.cssFloat = "left";
    titleLabel.style.fontFamily = "verdana,tahoma";
    titleLabel.innerHTML = "Javascript Inline Debugger";
    //titleLabel.style.marginTop = isIE() ? -14 : "-14px";
    titleLabel.style.marginLeft = isIE() ? 18 : "18px";
    title.appendChild(titleLabel);

    // 中间的显示部分
    var showPanel = document.createElement("div");
    showPanel.style.width = "250px";
    showPanel.style.height = isIE() ? "221px" : "219px";
    showPanel.style.fontSize = "11px";
    showPanel.style.padding = "0";
    showPanel.style.margin = "0";
    showPanel.style.overflow = "auto";
    showPanel.style.marginTop = isIE() ? -1 : "0";
    panel.appendChild(showPanel);

    // 命令输入框
    var cmdArea = document.createElement("div");
    panel.appendChild(cmdArea);

    var cmdTextbox = document.createElement("input");
    cmdTextbox.type = "text";
    cmdTextbox.style.width = "250px";
    cmdTextbox.style.height = "12px";
    cmdTextbox.style.fontSize = "12px";
    cmdTextbox.style.padding = "0";
    cmdTextbox.style.margin = "0";
    cmdTextbox.style.marginTop = isIE() ? -2 : "0";
    cmdTextbox.style.borderWidth = "0";
    cmdTextbox.style.borderTopWidth = "1px";
    cmdTextbox.style.paddingTop = "2px";
    cmdArea.appendChild(cmdTextbox);
posted on 2008-02-19 13:23  杜军  阅读(167)  评论(0)    收藏  举报