为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Text INPUTs behave strangely (blink) after text is selected

  • 2 个回答
  • 1 人有此问题
  • 1 次查看
  • 最后回复者为 jesse

more options

In Firefox 3.5.8 on Win XP Home SP3 I'm getting some weird behavior from text INPUTs. I tried it in safe mode and it made no difference. Part of the behavior can be seen without any scripting and even with scripting disabled, but the problem is that this behavior is interfering with behavior that I'm trying to script.

If there's a text INPUT that has characters selected when it loses focus, and then the INPUT is refocused by clicking with the mouse pointer over characters that were previously selected, Firefox flashes the previous selection for a split second and then inserts the cursor where the pointer was.

The problem is that I'm using the HTMLInputElement.select() method to select the text of the INPUT when it receives focus, and every-other-time Firefox screws it up and just inserts the cursor instead of selecting the text. That is, it alternates between the desired behavior (selecting the text) and the undesired behavior (inserting the cursor).

So for example say there's an INPUT that contains "abcde" and "abc" is selected when it loses focus and the selection disappears. If the mouse pointer is placed over "abc" and the INPUT is clicked, the previous selection flashes and then the cursor is inserted. If instead the pointer is over "de" when the INPUT is clicked, there's no flash -- the cursor is just inserted. To be safe, click on "e", since the left half of "d" will also trigger the flashing behavior.

Here is a demo of the problem:

http://www.jessemccarthy.net/public/firefox_input_blink.html


The goal is to have #custom_wager_radio checked and the text in #custom_wager_text selected whenever either is clicked.

It works fine in the following circumstances:

  • #custom_wager_radio is clicked
  • #custom_wager_radio's label is clicked
  • The blank part of #custom_wager_text is clicked
  • #custom_wager_text receives focus by tabbing to it


It screws up when the part of #custom_wager_text that contains text is clicked, if it was selected previously. Everything works fine in Opera 10.61.


To see the problem, perform these steps with JavaScript enabled:

1) Click on #custom_wager_text and type something in it.

2) Click "Custom" (#custom_wager_radio's label). That will select the text in #custom_wager_text.

3) Click on "Standard". That will blur #custom_wager_text.

4) Click any part of #custom_wager_text that contains text.

5) Try repeating steps 3 & 4. It will alternate between a) selecting the text in #custom_wager_text and b) flashing the previous selection then inserting the cursor.


You can also try selecting the text, then clicking again to insert the cursor, then clicking Standard, then clicking the text again. In that case the text will be selected, because it wasn't selected when #custom_wager_text lost focus.

You can disable JavaScript and try the test I described with "abcde" to see that the flashing behavior happens with scripting disabled.

Anybody know what the story is with this?

In Firefox 3.5.8 on Win XP Home SP3 I'm getting some weird behavior from text INPUTs. I tried it in safe mode and it made no difference. Part of the behavior can be seen without any scripting and even with scripting disabled, but the problem is that this behavior is interfering with behavior that I'm trying to script. If there's a text INPUT that has characters selected when it loses focus, and then the INPUT is refocused by clicking with the mouse pointer over characters that were previously selected, Firefox flashes the previous selection for a split second and then inserts the cursor where the pointer was. The problem is that I'm using the HTMLInputElement.select() method to select the text of the INPUT when it receives focus, and every-other-time Firefox screws it up and just inserts the cursor instead of selecting the text. That is, it alternates between the desired behavior (selecting the text) and the undesired behavior (inserting the cursor). So for example say there's an INPUT that contains "abcde" and "abc" is selected when it loses focus and the selection disappears. If the mouse pointer is placed over "abc" and the INPUT is clicked, the previous selection flashes and then the cursor is inserted. If instead the pointer is over "de" when the INPUT is clicked, there's no flash -- the cursor is just inserted. To be safe, click on "e", since the left half of "d" will also trigger the flashing behavior. Here is a demo of the problem: http://www.jessemccarthy.net/public/firefox_input_blink.html The goal is to have #custom_wager_radio checked and the text in #custom_wager_text selected whenever either is clicked. It works fine in the following circumstances: * #custom_wager_radio is clicked * #custom_wager_radio's label is clicked * The blank part of #custom_wager_text is clicked * #custom_wager_text receives focus by tabbing to it It screws up when the part of #custom_wager_text that contains text is clicked, if it was selected previously. Everything works fine in Opera 10.61. To see the problem, perform these steps with JavaScript enabled: 1) Click on #custom_wager_text and type something in it. 2) Click "Custom" (#custom_wager_radio's label). That will select the text in #custom_wager_text. 3) Click on "Standard". That will blur #custom_wager_text. 4) Click any part of #custom_wager_text that contains text. 5) Try repeating steps 3 & 4. It will alternate between a) selecting the text in #custom_wager_text and b) flashing the previous selection then inserting the cursor. You can also try selecting the text, then clicking again to insert the cursor, then clicking Standard, then clicking the text again. In that case the text will be selected, because it wasn't selected when #custom_wager_text lost focus. You can disable JavaScript and try the test I described with "abcde" to see that the flashing behavior happens with scripting disabled. Anybody know what the story is with this?

所有回复 (2)

more options

Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox.
http://forums.mozillazine.org/viewforum.php?f=25
You'll need to register and login to be able to post in that forum.

more options