createTextRange()是什么意思,谁能给出它的一些用法,最好全点

kasoo 2006-06-24 09:46:33
在网上搜了,没有搜到!
...全文
380 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Apq001 2006-06-24
  • 打赏
  • 举报
回复
MSDN这么写的:
Creates a TextRange object for the element.

Syntax

oTextRange = object.createTextRange()
Return Value

Returns a TextRange object if successful, or null otherwise.

Remarks

Use a text range to examine and modify the text within an object.

Examples

This example uses the createTextRange method to create a text range for the document, and then uses the text range to display all the text and HTML tags in the document.

<SCRIPT LANGUAGE="JScript">
var rng = document.body.createTextRange( );
if (rng!=null) {
alert(rng.htmlText);
}
</SCRIPT>
This example uses the createTextRange method to create a text range for the first button element in the document, and then uses the text range to change the text in the button.

<SCRIPT LANGUAGE="JScript">
var coll = document.all.tags("BUTTON");
if (coll!=null && coll.length>0) {
var rng = coll[0].createTextRange();
rng.text = "Clicked";
}
</SCRIPT>
三仙半 2006-06-24
  • 打赏
  • 举报
回复
我在MS word的VBA帮助中看到过这方面的内容,但没研究,你也可以去那里找,但装MS word时要选择VBA 帮助才行
jiayuanliao 2006-06-24
  • 打赏
  • 举报
回复
在MSDN上搜

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧