语法:
bSuccess = TextRange . expand ( sUnit )
参数:
sUnit : 必选项。字符串(String)。character | word | sentence | textedit character : 扩展一个字符。
word : 扩展一个词。一个词是以空格或其他空白字符(如:tab)为分隔的一组字符。
sentence : 扩展一个句子。一个句子是以结束标点符号(如:句号)为分隔的一组词。
textedit : 扩展整个封闭区域。
返回值:
bSuccess : 布尔值(Boolean)。false | true false : 区域没有被扩展。
true : 区域扩展成功。
说明:
扩展区域使局部单位能够被完全包含进去。
此方法在非 Microsoft® Win32® 平台上不可用。
<script>
var oTextRange;
function rdl_doExpand(){
with (document.all("oSelect")) var sParam=options[selectedIndex].value;
oTextRange=document.selection.createRange();
oTextRange.expand(sParam);
oTextRange.select();
}
function rdl_doInit(){
var oMessage=document.all("oMessage");
oTextRange=document.body.createTextRange();
oTextRange.moveToElementText(oMessage);
oTextRange.select();
}
window.onload=rdl_doInit;
</script>
<span id=oMessage>我是</span>要被选定的信息。
<br>
<table height=56><tr>
<td><select style="width:100px;" id=oSelect>
<option value="character" selected>character</option>
<option value="word">word</option>
<option value="sentence">sentence</option>
<option value="textedit">textedit</option>
</select></td>
<td><input type=button value=" 扩展 " onclick="rdl_doExpand();"></td>
</tr></table>
