1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IEのテキストボックスは、フォーカスが当たった状態でreadOnlyをオンにしても引き続き編集ができる

Last updated at Posted at 2015-09-04

jsFiddle サンプル

上記サンプルでは、テキストボックス内で Enter を入力すると、テキストボックスが readOnly になるように実装している。

Chrome や Firefox なら、 readOnly になった後は当然編集ができなくなる。

しかし、 IE だと readOnly が設定された後もフォーカスが外れるまで編集ができてしまう。
一応、一度フォーカスが外れれば、以後は普通に読み取り専用となる(バグだろ・・・)。

しかたないので、強制的に blur() を実行するようにすれば、 IE でも他のブラウザと同じように動くようになる。

修正版サンプル

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?