<table border=1 width="500" height="500" style="border-collapse:collapse;" oncontextmenu="return false;">
<script> 
for(var i=0;i<50;i++){
document.write("<tr>");
for(var j=0;j<50;j++){
document.write("<td onmousedown='if(event.button==2) alert(this.id);' id='td" + (i*50 + j) + "'></td>") }
document.write("</tr>");
}
</script> 
</table>

解决方案 »

  1.   

    onmouseup="alert(event.srcElement.id);"
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>Test </title>
    <style></style>
    <script>
    function init(){
    var tbl = document.getElementById("t1");
    for(var i=0;i<50;i++){
    var row = tbl.insertRow(i);
    for(var j=0;j<50;j++){
    var cell = row.insertCell(j);
    cell.id = "("+i+","+j+")";
    cell.innerHTML = i+""+j;
    cell.width = 30;
    row.insertBefore(cell,null);
    }
    }
    }
    document.onmousedown = function(e){
    e = e || event;
    target = e.target || e.srcElement;
    if(e.button == 2){
    alert(target.id);
    }
    };
    </script>
    </head>
    <body onload="init()">
    <table id="t1" border="1" bordercolor="#000000">

    </table> 
    </body>
    </html>