Prev: Google Adsense Account Approval With In 4 Hours
Next: FAQ Topic - Why do I get permission denied when accessing a frame/window? (2010-06-23)
From: Disc Magnet on 22 Jun 2010 12:56 For text elements there is a select() method to select text. I am trying to provide the user with this feature. If he clicks within a <textarea> element, all text is selected. This is easy to do using the select() method. But if he clicks again, all text should be unselected. For this to happen, I need to know whether any text is already selected in <textarea>. How can this be achieved?
From: Evertjan. on 22 Jun 2010 14:15 Disc Magnet wrote on 22 jun 2010 in comp.lang.javascript: > For text elements there is a select() method to select text. I am > trying to provide the user with this feature. If he clicks within a > <textarea> element, all text is selected. This is easy to do using the > select() method. But if he clicks again, all text should be > unselected. > > For this to happen, I need to know whether any text is already > selected in <textarea>. Why? > How can this be achieved? try: <textarea onclick='this.select();'> qwerty </textarea> -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
From: Disc Magnet on 22 Jun 2010 15:47 On Jun 22, 11:15 pm, "Evertjan." <exjxw.hannivo...(a)interxnl.net> wrote: > Disc Magnet wrote on 22 jun 2010 in comp.lang.javascript: > > > For text elements there is a select() method to select text. I am > > trying to provide the user with this feature. If he clicks within a > > <textarea> element, all text is selected. This is easy to do using the > > select() method. But if he clicks again, all text should be > > unselected. > > > For this to happen, I need to know whether any text is already > > selected in <textarea>. > > Why? Because if it is selected, I want to unselect the text. For that I need to know the current state of selection. > > > How can this be achieved? > > try: > > <textarea onclick='this.select();'> > qwerty > </textarea> > I tried this. But this doesn't work on IE and Firefox. It works only on Chrome. On IE and Firefox, if I click on the textarea for the second time, the text does not get unselected.
From: Asen Bozhilov on 22 Jun 2010 16:08 Disc Magnet wrote: > Evertjan wrote: > > Disc Magnet wrote: > > > For this to happen, I need to know whether any text is already > > > selected in <textarea>. > > > Why? > > Because if it is selected, I want to unselect the text. For that I > need to know the current state of selection. But why do you want such a behavior? That would break my normal browsing and probably I will close your page. For example I click on textarea and start writing, with your approach I will lose my entered text. Another problem is when I change the position of a caret with mouse click in textarea. What will be happen select/deselect? If you explain why do you want that, probably there is another answer on your question instead that terrible decision.
From: Disc Magnet on 22 Jun 2010 16:17
On Jun 23, 1:08 am, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote: > Disc Magnet wrote: > > Evertjan wrote: > > > Disc Magnet wrote: > > > > For this to happen, I need to know whether any text is already > > > > selected in <textarea>. > > > > Why? > > > Because if it is selected, I want to unselect the text. For that I > > need to know the current state of selection. > > But why do you want such a behavior? That would break my normal > browsing and probably I will close your page. For example I click on > textarea and start writing, with your approach I will lose my entered > text. Another problem is when I change the position of a caret with > mouse click in textarea. What will be happen select/deselect? If you > explain why do you want that, probably there is another answer on your > question instead that terrible decision. Many websites which generate code for the user to copy provide such a functionality where the whole textarea is selected with a single click. So, the user can click on the textarea and copy the text quickly. This doesn't break normal browsing because users don't want to edit the text. They simply want to copy the text. Such textarea also usually have the readonly="readonly" attribute set. Also, have a look at this example: http://delicious.com/help/tagometer |