Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Selecting partial text

Is there any way in DHTML to select text? (ie selecting some text from within
a <div> tag)
[100 byte] By [Roger] at [2007-11-9 16:16:42]
# 1 Re: Selecting partial text
You can select text within a body, button, or certain input elements using
the TextRange object. Here's a quick example:

function ShowSelection()
{
if (txtSource.value.length >= parseInt(txtLength.value) +
parseInt(txtStart.value))
{

var objTextRange = txtSource.createTextRange();
if (objTextRange)
{
objTextRange.collapse();
objTextRange.moveStart("character", parseInt(txtStart.value));
objTextRange.moveEnd("character", parseInt(txtLength.value));
objTextRange.select();
}
}
}

"Roger" <roger.burke@housing.qld.gov.au> wrote in message
news:3e472683$1@tnews.web.dev-archive.com...
>
> Is there any way in DHTML to select text? (ie selecting some text from
within
> a <div> tag)
kratka at 2007-11-11 23:36:23 >