removeChild Method  Internet Development Index --------------------------------------------------------------------------------Removes a child node from the object.What's New for Microsoft® Internet Explorer 6
This method now applies to the attribute object. SyntaxoRemove = object.removeChild(oNode)
ParametersoNode Required. Object that specifies the element to be removed from the document. Return ValueReturns a reference to the object that is removed.ResThe node to be removed must be an immediate child of the parent object.This method is accessible at run time. If elements are removed at run time, before the closing tag is parsed, areas of the document might not render.ExampleThis example uses the removeChild method to remove a bold element from a div.SHOWExample<HEAD>
<SCRIPT>
function removeElement()
{
try
{
//The first child of the div is the bold element.
var oChild=Div1.children(0);
Div1.removeChild(oChild);
}
catch(x)
{
alert("You have already removed the bold element.
Page will be refreshed when you click OK.")
document.location.reload();
}
}
</SCRIPT>
</HEAD>
<BODY>
<DIV ID=Div1 onclick="removeElement()">
Click anywhere in this sentence to remove this <B>Bold</B> word.
</DIV>
</BODY>
Standards InformationThis method is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 . Applies To[ Object Name ] 
Platform Version 
Win16:  
Win32:  
Unix:  
Mac:  
Windows CE:  
Version data is listed when the mouse hovers over a link, or the link has focus. 
 A, ACRONYM, ADDRESS, attribute, B, BDO, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, DD, DEL, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FONT, FORM, FRAMESET, HEAD, hn, HTML, I, IFRAME, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=hidden, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, INS, KBD, LABEL, LEGEND, LI, LISTING, MAP, MARQUEE, MENU, nextID, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP 
Move the mouse pointer over an element in the Applies To list to display availability information for the listed platforms. 
 

解决方案 »

  1.   

    妈的 你创建那么多东西干吗呢   想死吗
    如果是显示表格
    你可以先用fontpage创建好一个模板表格 表格的行列数设为最大(根据你的需要);
    显示的时候 有多少行就显示多少行(显示方法是将数据值插入到节点中);
    有多少列就显示多少列  多余的行和列全部删了
    知道吗  猪
      

  2.   

    我看csdn的都是猪 脑袋愚笨
      

  3.   

    dom好象有内存泄露问题回复人: saucer(思归/MVP)
    there used to be memory leaks, but it seems they fixed the memory leak problem in ScriptControl now, see
    http://groups.google.com/groups?q=scriptcontrol+memory+leak&hl=en&lr=&ie=UTF-8&oe=UTF-8&scoring=dbut with 脚本code size like 几十万行, the performance will be very badhttp://search.csdn.net/Expert/topic/865/865711.xml?temp=.493374你在CSDN的全文搜索搜索下“内存泄漏”,有很多讨论shaolin131083(达到)
    怎么现在不要钱了?呵呵
      

  4.   

    http://search.csdn.net/Expert/topic/1247/1247117.xml?temp=.486294
      

  5.   

    用DHTM比较慢,而且比较消耗资源,能少用不少用
    想其它办法代替
      

  6.   

    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>【 动态添加表格行】----【欢迎光临阿信的站点】 </title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="fason,阿信">
    <meta name="Keywords" content="fason,阿信,dhtml,table,表格,添加,行">
    <meta name="Description" content="用dhtml动态添加行">
    <style type="text/css">
    <!--
    body {
    margin:0;
    }
    body,td,span {
    font:12px Arial, Verdana;
    color: #000000;
    }
    .test {
    width: 200;
    height: 100;
    overflow: auto;
    border: 1px solid #888888;
    }
    -->
    </style>
    <script language="JavaScript">
    <!--
    function addRow1() {
    var d = new Date();
    var t = document.getElementById("table1");
    for(var i=0;i<1000;i++) {
    t.insertRow(0).insertCell(0).innerHTML = "fason阿信";
    }
    document.getElementById("description1").innerHTML = "总共用了" + (new Date() - d) + "ms";
    }function addRow2() {
    var d = new Date();
    var t = document.getElementById("table2").tBodies[0];
    for(var i=0;i<1000;i++) {
    var tr = document.createElement("tr");
    var td = document.createElement("td");
    td.innerHTML = "fason阿信";
    t.appendChild(tr);
    tr.appendChild(td);
    }
    document.getElementById("description2").innerHTML = "总共用了" + (new Date() - d) + "ms";
    };function addRow3() {
    var d = new Date();
    var t = document.getElementById("table3");
    var html = t.parentNode.innerHTML;
    var str = "";
    for(var i=0;i<1000;i++) {
    str += "<tr><td>fason阿信</td></tr>";
    }
    html = html.replace(/<\/tbody><\/table>/ig,'') + str + "</tbody></table>";
    t.parentNode.innerHTML = html;
    document.getElementById("description3").innerHTML = "总共用了" + (new Date() - d) + "ms";
    }function addRow4() {
    var d = new Date();
    var t = document.getElementById("table4").tBodies[0];
    for(var i=0;i<1000;i++) {
    t.appendChild(t.firstChild.cloneNode(true));
    }
    document.getElementById("description4").innerHTML = "总共用了" + (new Date() - d) + "ms";
    }
    //-->
    </script>
    </head>
    <body>
    <div align="center">
    <table border="0" width="778" cellpadding=0 cellspacing=0>
    <tr>
    <td style="padding:10px">
    <p> </p>
    <h4>【 动态添加表格行的多种方法】</h4>
    <hr>
    <p>动态添加表格行的方法很多,这里先介绍几种方法并比较一下添加的效果。</p>
    <p>1.用insertRow来添加表格行</p>
    <div class="test">
    <table border="1" width="100%" id="table1">
    <tr>
    <td>fason阿信</td>
    </tr>
    </table>
    </div>
    <input type=button value="添加行测试" onclick="addRow1()">
    <span id="description1"></span>

    <p>2.用dom的方法(appendChild)</p>
    <div class="test">
    <table border="1" width="100%" id="table2">
    <tr>
    <td>fason阿信</td>
    </tr>
    </table>
    </div>
    <input type=button value="添加行测试" onclick="addRow2()">
    <span id="description2"></span>


    <p>3.用HTML</p>
    <div class="test">
    <table border="1" width="100%" id="table3">
    <tr>
    <td>fason阿信</td>
    </tr>
    </table>
    </div>
    <input type=button value="添加行测试" onclick="addRow3()">
    <span id="description3"></span>


    <p>4.用cloneNode克隆!</p>
    <div class="test">
    <table border="1" width="100%" id="table4">
    <tr>
    <td>fason阿信</td>
    </tr>
    </table>
    </div>
    <input type=button value="添加行测试" onclick="addRow4()">
    <span id="description4"></span>
    <p>综以上几种方法的比较,效率相差还是比较大的,但各有各的好处和特点,尽管在应用中挑选合适自己的方法!</p>
    <center>
    <font color=red size=2>欢迎光临!</font><br>
    <font size=2>你是第<img src=http://counter.nease.net/cgi-bin/count.cgi?fason:34>位来访者!</font>
    </center>
    </td>
    </tr>
    </table>
    </div>
    </body>
    </html>
      

  7.   

    前几天我又发现创建元素可能不是内存上涨的最主要原因,因为我在一个iframe1里面定时动态刷新另外一个带有大量数据的iframe2,这样iframe2每次申请的内存会释放吗?