试试!
<script> 
var Open=false
function modify(tar){
if(Open) return 
var o=document.createElement("input"); 
var str=tar.innerHTML; 
tar.innerHTML=""; 
o.name="v"; 
o.type="text"; 
o.value=str; 
Open=true
o.onblur=function(){saveit(this.value,this)}; 
o.onDblClick=function(){window.document.readyState != null;}; 
o.onClick=function(){return false;}; 
tar.appendChild(o); 
o.select(); } function saveit(value,tar){ 
//alert('保存值为:'+value);//在这里异步保存到数据库 
tar.parentNode.innerHTML=value; 
Open=false

</script> 
<style type="text/css">
input,td{font-size:14px;font-family:宋体;}
input{width:90px;border:none;}
td{width:100px;height:16px;line-height:14px;word-break:break-all;word-wrap:break-word;}
table{width:300px;}
</style>
<table width="300" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" id="table1"> 
    <tr> 
        <td bgcolor="#FFFFFF" onclick="modify(this)">文字一 </td> 
        <td bgcolor="#FFFFFF" onclick="modify(this)"> 文字二 </td> 
        <td bgcolor="#FFFFFF" onclick="modify(this)">文字三 </td> 
    </tr> 
</table>

解决方案 »

  1.   

    这个你简单改下就可以了
    <script> 
    function modify(tar){ 
    var o=document.createElement("input"); 
    var str=tar.innerHTML; 
    tar.innerHTML=""; 
    onclick=tar.onclick;
    tar.onclick=function(){return false};
    o.name="v"; 
    o.type="text"; 
    o.value=str; 
    o.onblur=function(){o.parentNode.onclick=onclick;saveit(this.value,this)}; 
    tar.appendChild(o); 
    o.select(); } function saveit(value,tar){ 
    //alert('保存值为:'+value);//在这里异步保存到数据库 
    tar.parentNode.innerHTML=value; 

    </script> 
    <style type="text/css">
    input,td{font-size:14px;font-family:宋体;}
    input{width:90px;border:none;}
    td{width:100px;height:16px;line-height:14px;word-break:break-all;word-wrap:break-word;}
    table{width:300px;}
    </style>
    <table width="300" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" id="table1"> 
        <tr> 
            <td bgcolor="#FFFFFF" onclick="modify(this)">文字一 </td> 
            <td bgcolor="#FFFFFF" onclick="modify(this)"> 文字二 </td> 
            <td bgcolor="#FFFFFF" onclick="modify(this)">文字三 </td> 
        </tr> 
    </table>
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
            <title>Untitled Document</title>
        </head>
        <script>
            function modify(e,tar){
    if(window.event.srcElement!=tar){
    return(true);
    };
                var o = document.createElement("input");
                var str = tar.innerHTML;
                tar.innerHTML = "";            o.name = "v";
                o.type = "text";
                o.value = str;
                o.onblur = function(){
                    saveit(this.value, this)
                };
                o.onDblClick = function(){
                    window.document.readyState != null;
                };
                o.onClick = function(){
                    return false;
                };
                tar.appendChild(o);
                o.select();
                
            }
            
            function saveit(value, tar){
                //alert('保存值为:'+value);//在这里异步保存到数据库 
                tar.parentNode.innerHTML = value;
            }
        </script>
        <style type="text/css">
            input, td {
                font-size: 14px;
                font-family: 宋体;
            }
            
            input {
                width: 90px;
                border: none;
            }
            
            td {
                width: 100px;
                height: 16px;
                line-height: 14px;
                word-break: break-all;
                word-wrap: break-word;
            }
            
            table {
                width: 300px;
            }
        </style>
        <body>
        <table width="300" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" id="table1">
        <tr>
            <td bgcolor="#FFFFFF" onclick="modify(event,this)">
                文字一 
            </td>
            <td bgcolor="#FFFFFF" onclick="modify(event,this)">
                文字二 
            </td>
            <td bgcolor="#FFFFFF" onclick="modify(event,this)">
                文字三 
            </td>
        </tr>
        </body>
    </table>
    </html>