<!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(){
if(event.srcElement.tagName.toLowerCase()=='td')
alert("行:"+(event.srcElement.parentNode.rowIndex+1)+"列:"+(event.srcElement.cellIndex+1));
}
function selectWord() {
var oSource = window.event.srcElement ;
alert( "oSource.isTextEdit ;" + oSource.isTextEdit );
alert( "oSource.TextEdit ;" + oSource.textEdit );
if (!oSource.isTextEdit) {
oSource = window.event.srcElement.parentTextEdit;
alert( "oSource ;" + oSource );
}
alert( "oSource ;" + oSource );
if (oSource != null) {
var oTextRange = oSource.createTextRange();
alert("oSource.tagName :" + oSource.tagName);
oTextRange.moveToElementText(window.event.srcElement);
oTextRange.collapse();
oTextRange.expand("word");
oTextRange.select();
}
}
</script>
</head>
<body>
<table align="center" οnclick="tdclick()" 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>
<TABLE>
<TR>
<TD οnclick="selectWord()"><INPUT TYPE="text" NAME="aa" value="你好"></TD>
</TR>
</TABLE>
</body>
</html>