Bug 8114 - select method doesn't highlight text field contents for onclick
: select method doesn't highlight text field contents for onclick
Status: REOPENED
: WebKit
HTML DOM
: 417.x
: Macintosh Mac OS X 10.4
: P2 Normal
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2006-03-31 17:05 PST by
Modified: 2007-05-18 23:18 PST (History)


Attachments
Test from Comment #0 (331 bytes, text/html)
2006-04-01 15:51 PST, David Kilzer (:ddkilzer)
no flags Details


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2006-03-31 17:05:51 PST
object.select() should highlight and select the contents of the (text field) object according to the DOM. This doesn't seem to happen, the object gets focus, but the contents are not selected.

Example code:

<html>
<head>
<script type="text/javascript">
function selText() {
   document.getElementById("myText").select()
}
</script>
</head>

<body>
<form>
   <input size="40" type="text" id="myText" value="A cat played with a ball in the garden">
   <input type="button" value="Select text" onclick="selText()"> 
</form>
</body>

</html>
------- Comment #1 From 2006-04-01 15:51:03 PST -------
Created an attachment (id=7450) [details]
Test from Comment #0
------- Comment #2 From 2006-04-01 15:52:13 PST -------
Confirmed on Safari 2.0.3 (417.9.2) on Mac OS X 10.4.5 (8H14).
------- Comment #3 From 2006-04-01 15:54:01 PST -------
However, this bug has been fixed on ToT as of (at least) r13607 (built locally).  Therefore, closing as RESOLVED/FIXED.
------- Comment #4 From 2006-04-03 12:50:19 PST -------
Okay, one behavior is fixed, however it still fails in another example. If the textfield element is clicked to obtain focus or the event is set on the onClick (or indirectly the onFocus fired by a click derived focus event) handler the text is selected then the cursor steals the select behavior and the text is no longer selected.

Example code 2:

<html>
<head>
<script type="text/javascript">
function selText() {
   document.getElementById("myText").select()
}
</script>
</head>

<body>
<form>
   <input size="40" type="text" id="myText" value="A cat played with a ball in
the garden" onclick="selText()">
</form>
</body>

</html>
------- Comment #5 From 2007-05-18 10:27:18 PST -------
I've looked for an appropriate place to put this, and not sure if it merits a separate thread so I'll start here as they may be related:  

sometimes, when I open a new Firefox window after using it for a while (still w/ tons of free real memory and now pageouts on a 2 GB RAM machine) I am unable to hit the TAB key to select and enter text into the Search Engine entry area.

There is a greyed-out indicator of the Search Engine default in the area that is supposed to dissapear when the cursor gets there.  Instead the word "Google" in this case remains and the subsequent typing/text entry ends up being appended to the word Google, then you can't enter.  Trying Cmd-A for "select all" in os x, or trying deleting all the text doesn't work either....after entering the text the Enter key is still not functional.

Closing the window and opening another doesn't usually help...when it gets to this state you need to quit and restart...

I've reached this problem several times, but it is infrequent and not easy to test for someone of my skill level/background.
------- Comment #6 From 2007-05-18 23:17:30 PST -------
(In reply to comment #5)
> I've looked for an appropriate place to put this, and not sure if it merits a
> separate thread so I'll start here as they may be related:  
> 
> sometimes, when I open a new Firefox window after using it for a while (still
> w/ tons of free real memory and now pageouts on a 2 GB RAM machine) I am unable
> to hit the TAB key to select and enter text into the Search Engine entry area.

Mark, if this is really a Firefox bug, you want to use:  http://bugzilla.mozilla.org/

I suggest using this page to create a new bug (after you create an account):  https://bugzilla.mozilla.org/enter_bug.cgi

Please note that http://bugs.webkit.org/ is for Apple's Safari web browser.  Thanks!
------- Comment #7 From 2007-05-18 23:18:08 PST -------
Mark, please see Comment #6.