/* 页面reset*/
    function pageClear(){
        //searchList.rows.length = 0;
        searchList.innerHTML ="<TBODY><tr><td>URL</td><td width='500px'>Text</td></tr></TBODY>";
        
    }     ...
        <table id="searchList" border="1px" >
<tr>
        <td>URL</td><td width="500px">Text</td>
</tr>
</table>
我想利用rows.length或者innerHTML清空table 
莫名其妙的都抛出这个错 是什么原因??
Message: Unknown runtime error

解决方案 »

  1.   

    直接 id.属性?不用getElementById?
    弓虽
      

  2.   


    在IE中使用如下语句:table.innerHTML = content; 动态修改table的HTML内容时,出现“未知运行错误”。
    错误原因:
      在IE浏览器中,table的innerHTML属性是只读的,不能更改。类似的还有THEAD、TFOOT和TR(唯一例外的是td)。
      

  3.   

    <script language="javascript">
    function pageClear(){
    var searchList = document.getElementById("searchList");
    searchList.innerHTML ="";
    }
    </script><table id="searchList" border="1px" onclick="pageClear()">
    <tr>
    <td>URL</td>
    <td width="500px">Text</td>
    </tr>
    </table>没问题啊
      

  4.   

    楼主要是在IE下的话必须得用这种方法:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head><body>
        <table id="a">
            <tr></tr>
            <tr></tr>
        </table>
        <input type="button" value="click" id="c" onclick="c()" />
        <script>
            //add row
            function c(){
            tbl = document.getElementById("a");
            rowsLen = tbl.rows.length;
            row = tbl.insertRow(rowsLen);        
            
            //create head tag
            textNode = document.createTextNode('1111');        
            cell = row.insertCell(0)//表示列,从0开始,要是加两列,就是row.insertCell(0),row.insertCell(1)
            cell.setAttribute("hight","22");
            cell.appendChild(textNode);        
            row.appendChild(cell); 
            
            tbl.appendChild(row);
            }
        </script>
    </body>
    </html>
      

  5.   

    ie所有版本都是这样吗?
    还有  searchList.rows.length = 0;为什么也不行了
    因为记得我以前这么用过
      

  6.   

    我这么写就是不想使用循环 然后deleteRow之类的方法
      

  7.   


    昨天我也试了半天,我IE8下面不能用innerHTML,就是按你这么写的,就报错。
    我后来查百度,才知道innerHTML对于table是只读的。在IE下
    呃~·谁让他是IE呢
      

  8.   

    可愁死我了
    那这个方法也是不好用了
    以前可以的,,,
    不知道是不是跟IE8有什么关系
    searchList.rows.length = 0;
      

  9.   

    可能你的不是IE8 帮我试一下这个好用不
    searchList.rows.length = 0;
      

  10.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head><body><table id="searchList" border="1px" onclick="pageClear()">
            <tr>
                <td>URL</td><td width="500px">Text</td>
            </tr>
        </table>  <script type="text/javascript">
       function pageClear(){
            alert(searchList.rows.length)
            //searchList.innerHTML ="<TBODY><tr><td>URL11</td><td width='500px'>Text</td></tr></TBODY>";
            
        }    
      </script></body>
    </html>
      

  11.   

    算了 换其他办法吧
    我给<table外面加个层用innerHTML解决了