Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

enter does not work in textarea in Internet Explorer 8

When I press enter in a textarea which has whitespace attribute is set to nowrap through css, it is ineffective. No new line is created. Instread a simple whitespace appears. This is only true in IE8. I Have tried current version of Opera,Chrome and Firefox and I have not encountered such problems. Do you have some solution for this?

Thanks..

I have this:

.gwt-TextArea
{
white-space:nowrap;
}

where gwt-TextArea sets the textarea.

Also, I have tried

.gwt-TextArea
    {
    white-space:pre;
    }

It seems to give the same result.

like image 991
Aftershock Avatar asked Aug 15 '09 16:08

Aftershock


2 Answers

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?

like image 167
jimyi Avatar answered Oct 02 '22 05:10

jimyi


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.

like image 40
PhistucK Avatar answered Oct 02 '22 06:10

PhistucK