给你一个例子 看看就知道了 :)
<HTML><HEAD>
<TITLE>moveToPoint Example</TITLE>
<script for=document event=onclick>
var r
if(window.event.srcElement.isTextEdit)
{
r=window.event.srcElement.createTextRange();
}else{
var el=window.event.srcElement.parentTextEdit;
r=el.createTextRange();
}
r.moveToPoint(window.event.x, window.event.y);
r.expand("word");
r.select();
</script>
</HEAD>
<BODY><H1 id=myH1>Click on a word and it will highlight</H1><TEXTAREA>
There's text in this element too that you could click on
</TEXTAREA></BODY></HTML>
<HTML><HEAD>
<TITLE>moveToPoint Example</TITLE>
<script for=document event=onclick>
var r
if(window.event.srcElement.isTextEdit)
{
r=window.event.srcElement.createTextRange();
}else{
var el=window.event.srcElement.parentTextEdit;
r=el.createTextRange();
}
r.moveToPoint(window.event.x, window.event.y);
r.expand("word");
r.select();
</script>
</HEAD>
<BODY><H1 id=myH1>Click on a word and it will highlight</H1><TEXTAREA>
There's text in this element too that you could click on
</TEXTAREA></BODY></HTML>
<HEAD><TITLE>Another FindText demo</TITLE>
<SCRIPT>
function findme() {
var rng = document.body.createTextRange();
for (i=0; rng.findText("sample")!=false; i++) {
rng.text = "final";
}
}
</SCRIPT>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-8859-1">
<META NAME="AUTHOR" CONTENT="InetSDK">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="ROBOTS" CONTENT="noindex"><!-- SAMPLE_STYLE_START -->
<LINK REL="stylesheet" HREF="/workshop/basicSDKIE4.css" TYPE="text/css">
<!-- SAMPLE_STYLE_END -->
</HEAD>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END--><BODY TOPMARGIN=0 LEFTMARGIN=0 BGPROPERTIES="FIXED" BGCOLOR="#FFFFFF" LINK="#000000" VLINK="#808080" ALINK="#000000">
<BLOCKQUOTE CLASS="body"><DIV style="position:absolute; top:20; font-size:14pt;">This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text. This is sample text.</DIV><SPAN style="position:absolute; top:100; width=150; background:yellow; font-color=#FF0000 width:200; text-align=center" onclick="findme()">click here to replace instances of sample</SPAN></BLOCKQUOTE>
</BODY>
</HTML>