给你个例子看看
<input onMouseOut="machwas()" type="Text"
 value="Markieren Sie einige W&ouml;rter dieses Satzes. Oder von diesem."><script language="JScript">
<!--
function machwas()
{
 a = document.selection.createRange();
 org = a.text;
 dup = a; dup.expand("character"); ch = dup.text;
 dup = a; dup.expand("word"); wo = dup.text;
 dup = a; dup.expand("sentence"); sen = dup.text;
 dup = a; dup.expand("textedit"); te = dup.text;
 alert('Orginal: '+org+
       '\nCharacter: '+ch+
       '\nWord: '+wo+
       '\nSentence: '+sen+
       '\nTextedit: '+te);
}
//-->
</script> 
 

解决方案 »

  1.   

    ExampleThis example creates a range from the current selection and uses the expand method to ensure that any word partially enclosed in the range becomes entirely enclosed in the range.var rng = document.selection.createRange();
    rng.expand("word");
      

  2.   

    To zhaoweiwei(轩辕大侠) 
      你真幽默,真的不用我上msdn了:你给我直接搬过了,谢谢了
      

  3.   

    msdn是我看过的最好的help,不看是你的损失,弄计算机E文差一定要补起来