Important Notice: We're experiencing email notification issues. If you've posted a question in the community forums recently, please check your profile manually for responses while we're working to fix this.

On Monday the 3rd of March, around 5pm UTC (9am PT) users may experience a brief period of downtime while one of our underlying services is under maintenance.

搜索 | 用户支持

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

详细了解

FF differs from other browsers - keystroke is swallowed when creating input element

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

more options

Hi all

I have found a workaround for this problem, so its importance is low, but I will be interested in any comments.

I am creating a control in javascript which represents an editable grid - a bit like a spreadsheet. The cells consist of 'span' elements with text nodes. I can move around the grid with the keyboard or the mouse.

The user can signal their intent to edit a cell in three ways - double-click, press F2, or just start typing. When any of these are detected, I hide the span element and replace it with a text input element.

If they doubleclick or press F2, the initial content of the input element must be the same as the content of the text node. If they type a character, the initial content must be the character they typed.

In all other browsers I have tested (IE8, Opera, Chrome and Safari) the keystroke entered is still 'active', so it automatically becomes the first character in the input element. In FF, it does not.

My workaround is to store the keystroke entered in a variable, then create the input element, then update the 'value' attribute of the element with the string value of the keystroke, then call setSelectionRange(1, 1) so that the insertion point is positioned after the character.

I can live with this, but it would be nice if I could get FF to behave the same as the others, and render the workaround unnecessary.

Hi all I have found a workaround for this problem, so its importance is low, but I will be interested in any comments. I am creating a control in javascript which represents an editable grid - a bit like a spreadsheet. The cells consist of 'span' elements with text nodes. I can move around the grid with the keyboard or the mouse. The user can signal their intent to edit a cell in three ways - double-click, press F2, or just start typing. When any of these are detected, I hide the span element and replace it with a text input element. If they doubleclick or press F2, the initial content of the input element must be the same as the content of the text node. If they type a character, the initial content must be the character they typed. In all other browsers I have tested (IE8, Opera, Chrome and Safari) the keystroke entered is still 'active', so it automatically becomes the first character in the input element. In FF, it does not. My workaround is to store the keystroke entered in a variable, then create the input element, then update the 'value' attribute of the element with the string value of the keystroke, then call setSelectionRange(1, 1) so that the insertion point is positioned after the character. I can live with this, but it would be nice if I could get FF to behave the same as the others, and render the workaround unnecessary.

所有回复 (2)

more options

A good place to ask advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.
The helpers at that forum are more knowledgeable about web development issues.
You need to register at the mozillaZine forum site in order to post at that forum.

See http://forums.mozillazine.org/viewforum.php?f=25

more options

Thanks - I will try there.