=波波日志 > HTML/WML/CSS兼容/XML > createTextRange Method=

[转]createTextRange Method

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>

Standards Information

There is no public standard that applies to this method.

 

http://msdn.microsoft.com/en-us/library/ms536401(v=VS.85).aspx

类别:HTML/WML/CSS兼容/XML 作者:转载 日期:2010-04-30 【评论:0】 
上一篇:TextRange Object 
下一篇:Selection Prototype
 
暂时没有评论!
发表留言
  • *昵称:
  • 头像:
  • 电子邮件: [留下您的邮件,方便管理员回复您。]
  • 个人网站: *验证码:
声明:本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载或引用的作品侵犯了您的权利,请通知我们,我们会及时删除!
Powered by showbo,©2012WEB编程网桂ICP备05005887号 京公网安备1101055090