[Javascript] Text selection property/method?
William T. Simmons
tsimmons at employmentlawadvisors.com
Wed Feb 11 01:57:02 CST 2004
How about something like this, once the mouse-drag event has been trapped:
var rangeRef = document.selection.createRange();
(from Danny Goodman's JavaScript Bible, 4th Ed., Chap. 19)
Once the selection range object is created, you can then perform operations
on it, such as with "execCommand()":
"rangeRef.execCommand("BackColor","false","yellow")", or
"rangeRef.execCommand("Italic").
HTH,
Tommy Simmons
Employment Law Advisory Network
www.employmentlawadvisors.com
----- Original Message -----
From: "Peter Brunone" <peter at brunone.com>
To: <javascript at latech.edu>
Sent: Tuesday, February 10, 2004 11:35 PM
Subject: [Javascript] Text selection property/method?
> List,
>
> I'm trying to find a way (in IE right now, but may need it for
> Mozilla later) to identify and alter the region selected by a mouse drag
> (usually identified by highlighting in a color opposite the background).
> The selected text will most likely be in a TD. Any thoughts on what
> this mysterious attribute might be called?
>
> Cheers,
>
> Peter Brunone
More information about the Javascript
mailing list