enter does not work in textarea in Internet Explorer 8

删除回忆录丶 提交于 2019-11-30 14:33:08

This article says Internet Explorer ignores line breaks with white-space: nowrap.

Their fix is to use white-space: pre. Does that get you your desired behavior?

So, the solution is, unfortunately, this -
For Internet Explorer 7, any white-space value other than pre will cause this issue.
For Internet Explorer 8, any white-space value other than pre-wrap will cause this issue.

I have not tried Internet Explorer 9, though.
In case this is happening there as well, just create a blank page with (a doctype and) a <textarea>, open it and press F12. In the console ("Scripts" tab), type console.log(document.getElementsByTagName("TEXTAREA")[0].currentStyle.whiteSpace) and simply use the value that is displayed within the output as the value of the white-space property of the <textarea>.

Update

I tried Internet Explorer 11. In emulation modes since Internet Explorer 7 mode, it behaves like Chrome in quirks mode (meaning, only white-space: normal and white-space: nowrap cause this issue). I guess they (unintentionally?) backported some fix to most of the emulation modes.

Does it have to be CSS solution? If not, you could assign attribute wrap="off" for textarea.

The available options (found here: Quirksmode.org), are:

  • normal
  • nowrap, IE5.5+
  • pre, IE6+
  • pre-line IE8
  • pre-wrap IE8

It might be worth using white-space: normal (I don't have IE with which to experiment, but I imagine that normal would be available by default if it's possible to alter the state to abnormal).


Edited, with respect to the OP's comment/response.

Are you using a doctype? (I recommend using <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">)

Assuming that you are, is there any chance you could post a link to a demo-page? Or perhaps post your (x)html and css, to see if there's some manner of style-override, or typo, preventing the css being applied?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!