[Project_owners] How to get selected text

Biju G C bijumaillist at yahoo.com
Sat Mar 13 22:22:53 EST 2004

 --- "Jaap A. Haitsma" <jaap at haitsma.org> wrote: > Hi,
> I'm trying to obtain the text that is selected. If text is selected in a 
> web page (in Firefox) or in a message (in Thunderbird) I can obtain the 
> text very easily by calling gContextMenu.searchSelected(). However if 
> the selected text is inside a <textarea> or <input> tag (Firefox) or in 
> the message composer (Thunderbird) I don't manage to get the selected text.
> I've been looking in the mozilla cross reference 
> http://lxr.mozilla.org/mozilla/ for quite a while to try to figure out 
> how the command copy works (because that is available at the points I 
> want to get the selection), but sofar I'm still not able to get it 
> working. :(

if we know the input or textarea element we can use
selectionStart, selectionEnd etc.

But I dont know how to find current selected input 
or textarea element. we should be able capture 
"onFocus" event of all elements in a window 

using  windowobject.addEventListener("focus",onfocus,true) 

at "window level", then the last focused  element is current element

if you are sucessful pl. share the code

Yahoo! Messenger - Communicate instantly..."Ping" 
your friends today! Download Messenger Now 

More information about the Project_owners mailing list