怎樣讓你的表格可編輯???


<HEAD>
<STYLE>
.td1 { color: white; background-color: orange;}
.td2 { color: white; background-color: #0099ff;}
.td3 { color: white; background-color: #336699;}
</STYLE>
<SCRIPT>
function editCell (cell) {
if (document.all) {
cell.innerHTML = '<INPUT ID="editCell"
ONCLICK="event.cancelBubble = true;"
ONCHANGE="setCell(this.parentElement, this.value)"
ONBLUR="setCell(this.parentElement, this.value)"
VALUE="' + cell.innerText + '"
SIZE="' + cell.innerText.length + '">';
document.all.editCell.focus();
document.all.editCell.select();
}
else if (document.getElementById) {
cell.normalize();
var input = document.createElement('INPUT');
input.setAttribute('value', cell.firstChild.nodeValue);
input.setAttribute('size', cell.firstChild.nodeValue.length);
input.onchange = function (evt) {
setCell(this.parentNode, this.value); };
input.onclick = function (evt) {
evt.cancelBubble = true;
if (evt.stopPropagation)
evt.stopPropagation();
};
cell.replaceChild(input, cell.firstChild);
input.focus();
input.select();
}
}
function setCell (cell, value) {
if (document.all)
cell.innerText = value;
else if (document.getElementById)
cell.replaceChild(document.createTextNode(value), cell.firstChild);
}
</SCRIPT>
</HEAD>
<BODY>
<TABLE BORDER="2">
<TR>
<TD ONCLICK="editCell(this);" CLASS="td1">歡迎光臨</TD>
<TD ONCLICK="editCell(this);" CLASS="td2">[孟憲會之精彩世界]</TD>
<TD ONCLICK="editCell(this);" CLASS="td3">http://lucky.myrice.com</TD>
</TR>
</TABLE>
</BODY>
</HTML>
**************************************
這個網址也不錯---->http://hi.baidu.com/senty/blog/item/0b0a8226797112128b82a152.html/cmtid/52ef510f7504b3206159f3cf
**************************************

本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/net_lover/archive/2001/06/27/6869.aspx
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章