Hello, Does anyone know if it is possible for JavaScript to detect what text is currently selected by a user? I would like to allow the user to select some text and then grab that text using JS. I saw these guys do it : http://www.enlighter.com/ but I''m not sure if its possible to do this using JS only or if it needs a browser extension. Thanks! --Dave.
document.getSelection() .. many many bookmarklets use this, as do wysiwig textarea doo-hickies -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of David Teare Sent: Wednesday, 30 November 2005 10:19 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] OT - Detect selected text with JavaScript Hello, Does anyone know if it is possible for JavaScript to detect what text is currently selected by a user? I would like to allow the user to select some text and then grab that text using JS. I saw these guys do it : http://www.enlighter.com/ but I''m not sure if its possible to do this using JS only or if it needs a browser extension. Thanks! --Dave. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Thank-you, that worked like a charm! On 29-Nov-05, at 9:18 PM, Bruce Collier wrote:> document.getSelection() > > .. many many bookmarklets use this, as do wysiwig textarea doo-hickies > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of > David > Teare > Sent: Wednesday, 30 November 2005 10:19 AM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails-spinoffs] OT - Detect selected text with JavaScript > > > Hello, > > Does anyone know if it is possible for JavaScript to detect what text > is currently selected by a user? I would like to allow the user to > select some text and then grab that text using JS. > > I saw these guys do it : http://www.enlighter.com/ but I''m not sure > if its possible to do this using JS only or if it needs a browser > extension. > > Thanks! > --Dave. > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > Important notice: This message is intended for the individual(s) > and entity(s) addressed. The information contained in this > transmission and any attached, may be confidential and may also be > the subject of legal privilege, public interest immunity or legal > professional privilege. Any review, retransmission, dissemination > or other use of, taking of any action in reliance upon this > information by person or entities other than the recipient is > prohibited and requires authorization from the sender. If you are > not the addressee indicated in this message (or responsible for > delivery of the message to such person) you may not copy or deliver > this message to anyone. In such cases you should destroy this > message and kindly notify the sender by reply email. > > WARNING: Although Infocomp has taken reasonable precautions so that > no viruses are present in this e-mail, the company cannot accept > responsibility for any loss or damage arising from the use of e- > mail attachments. > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Mind you, I just noticed this message in the JavaScript console for my shiny new Firefox 1.5: "Deprecated method document.getSelection() called. Please use window.getSelection() instead." That''s very polite and gentle .. perhaps we should all pay attention. -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org]On Behalf Of David Teare Sent: Wednesday, 30 November 2005 1:46 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] OT - Detect selected text with JavaScript Thank-you, that worked like a charm! On 29-Nov-05, at 9:18 PM, Bruce Collier wrote: document.getSelection() .. many many bookmarklets use this, as do wysiwig textarea doo-hickies -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> [ mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> ]On Behalf Of David Teare Sent: Wednesday, 30 November 2005 10:19 AM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> Subject: [Rails-spinoffs] OT - Detect selected text with JavaScript Hello, Does anyone know if it is possible for JavaScript to detect what text is currently selected by a user? I would like to allow the user to select some text and then grab that text using JS. I saw these guys do it : http://www.enlighter.com/ <http://www.enlighter.com/> but I''m not sure if its possible to do this using JS only or if it needs a browser extension. Thanks! --Dave. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs <http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs> Important notice: This message is intended for the individual(s) and entity(s) addressed. The information contained in this transmission and any attached, may be confidential and may also be the subject of legal privilege, public interest immunity or legal professional privilege. Any review, retransmission, dissemination or other use of, taking of any action in reliance upon this information by person or entities other than the recipient is prohibited and requires authorization from the sender. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person) you may not copy or deliver this message to anyone. In such cases you should destroy this message and kindly notify the sender by reply email. WARNING: Although Infocomp has taken reasonable precautions so that no viruses are present in this e-mail, the company cannot accept responsibility for any loss or damage arising from the use of e-mail attachments. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs <http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs> _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs