????
<script>
function TableDesigner(id,rowCount,colCount){ 
    this.id=id; 
    this.rowCount=rowCount; 
    this.colCount=colCount; 
}
TableDesigner.prototype.createTable=function(){
    alert(this.id);
}
var td=new TableDesigner("idididi",10,10);
td.createTable();
</script>

解决方案 »

  1.   

    this.cell.attachEvent("onclick",this.onClick); this.cell.attachEvent("onclick",TableCell.prototype.onClick);
      

  2.   

    对不起,我的意思是,由此代码生成的表格中的单元格,在响应onClick事件的时候,得不到单元格对象的rowNo和colNo.这个问题怎么解决?
      

  3.   

    function   TableCell(rowNo,colNo){ 
    //标明自己的行列号 
    this.rowNo=rowNo; 
    this.colNo=colNo; 
    //创建单元格元素 
    this.cell=document.createElement("td"); 
    //添加响应事件 
    this.cell.TableCell=this;
    this.cell.attachEvent("onclick",TableCellOnClick); 
    //添加内容 
    currentText   =   document.createTextNode("第"+this.rowNo+"行,第"+this.colNo+"列"); 
            this.cell.appendChild(currentText); 
    return   this.cell; 

    function TableCellOnClick(){
        var tc=this.TableCell;
        if("undefined"==typeof(tc.rowNo) ¦ ¦"undefined"==typeof(tc.colNo)){ 
            alert("undefined"); 
            return; 
        }
        alert(tc.rowNo+":"+tc.colNo); 
    }
      

  4.   

    this.cell.attachEvent("onclick",TableCellOnClick); 监听方式,TableCellOnClick里面this不知道是不是指向那个cell~~
    如果不行,试试改为
    this.cell.onclick=TableCellOnClick;
    看看情况是否一样~~~
      

  5.   

    找到答案了:
    var refThis = this;
    this.cell.attachEvent("onclick",  function () {refThis.onClick();});
    具体的原理我不是很清楚。跟javascript的运行机制有关。