evt=evt?evt:window.event

<!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" xml:lang="en" lang="en">
<head>
  <title></title>
  <script type="text/javascript">

    function tdclick(evt){

    evt=evt?evt:window.event
    if(document.all)
    {
        if(evt.srcElement.tagName.toLowerCase()=='td')
             alert("行:"+(evt.srcElement.parentNode.rowIndex+1)+"列:"+(evt.srcElement.cellIndex+1));
    }
    else
    {
     if(evt.target.tagName.toLowerCase()=='td')
             alert("行:"+(evt.target.parentNode.rowIndex+1)+"列:"+(evt.target.cellIndex+1));
        //alert(evt);
    }
     }
window.onload=function(){
var obj=document.getElementsByTagName("table")
for(i=0;i<obj.length;i++){
    obj[i].onclick=tdclick;
}
}
  </script>
</head>
<body>
<table align="center" width="100%" height="400" cellspacing="1" border="1" bordercolor="#000000" bordercolorlight="#000000" bordercolordark="#C0C0C0" bgcolor="#C0C0C0">
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
    <td> </td>
    <td> </td>
    <td> </td>
  </tr>
</table>
</body>
</html>


posted @ 2011-01-11 14:52  @vip_c  阅读(1358)  评论(0编辑  收藏  举报