Re: Deselecting text in input text box
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Deselecting text in input text box

From: RobG <rgqld@iinet.net.au>
Date: Tue Feb 28 2006 - 01:00:15 CET

len.hartley@gmail.com wrote:
> I have a text input box and I don't want the text to be selected either
> when the user tabs to the item or if the user clicks on it.

What are you trying to achieve?

It is impossible to reliably prevent either of the above using script.
Making the element readonly will prevent the user from changing the
value using normal keyboard input. Making the element disabled will
knobble it even further, but neither will reliably stop the user from
selecting it or copying the value that's in there.

> Now the function below which I found from 2002 in the archive works
> fine for IE 6 but it works in neither Netscape 7 nor Firefox 1.0.

It 'works' in IE only in a limited way. Once I've clicked on the input,
  or tabbed to it, I can then select the text in it (tab to it then
press Ctrl+A). I can also drag across the input to select it, then copy
and paste into some other application.

If I turn off scripting, the script fails to do anything at all.

> I'm hoping some of you might have an alternative suggestion or insight
> for Netscape and Firefox.

If you explain what you are trying to achieve, maybe.

[...]

-- 
Rob
Received on Mon May 1 03:40:17 2006