Mozilla サポートの検索

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

詳しく学ぶ

このスレッドはアーカイブに保管されました。 必要であれば新たに質問してください。

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

  • 2 件の返信
  • 1 人がこの問題に困っています
  • 6 回表示
  • 最後の返信者: 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.