<SCRIPT LANGUAGE="
javascript">
<!--
function test2()
{
var t=document.getElementByIdx_x("test")
var o=t.createTextRange()
alert(o.text)
o.moveStart("character",2)
alert(o.text)
o.select()
}
//-->
</SCRIPT>
<input type='text' id='test' name='test'><input type=button onclick='test2()' value='test' name='test3'>
对textarea中的内容,进行选中后,加效果
<script language="JavaScript">
<!--
function bold(){
Qr=document.selection.createRange().text;
if(!Qr || document.selection.createRange().parentElement().name!='description')
{
txt=prompt('Text to be made BOLD.','');
if(txt!=null && txt!='') document.form1.description.value+=''+txt+'';
}
else{
document.selection.createRange().text=''+document.selection.createRange().text+'';
document.selection.empty();
}
}
//-->
</script>
<input type="button" value="加粗" onclick="bold();" />
<textarea name="description" style="width: 436px; height: 296px">选中我,点击加粗</textarea>