[Javascript] Text selection property/method?

Peter Brunone peter at brunone.com
Wed Feb 11 13:51:05 CST 2004


	Thanks to everyone who responded; I have what I need for now.

	David (or anybody), if you come across a valid approach for
Mozilla, let me know!

Cheers,

Peter

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu] On Behalf Of David Lovering

Tommy's method is OK for IE, but a prelim test shows that it doesn't
work on the Netscape/Mozilla boxes I tried.

-- Dave Lovering

----- Original Message ----- 
From: "William T. Simmons" <tsimmons at employmentlawadvisors.com>

> 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>
>
> > 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