in IE only new line created as <p>

Jul 11, 2010 at 4:31 PM

In Chrome and FF new line (press "Enter" / Carriage return) added as "div" or nothing but in IE it adds <p>.

This adding extra line in the text (in IE7 or IE8).

Please help or guide me to the code that handle this.

Thanks,

Itay

 

 

Oct 18, 2010 at 3:43 PM
itayher wrote:

In Chrome and FF new line (press "Enter" / Carriage return) added as "div" or nothing but in IE it adds <p>.

This adding extra line in the text (in IE7 or IE8).

Please help or guide me to the code that handle this.

Thanks,

Itay

 

 

 Did anyone has a solution for this ?

Jun 8, 2012 at 3:03 PM

I have noticed that all jQuery based editor have this behavior, to avoid this i have done:

 

 $('#' + txtEditor).htmlarea({
        loaded: function () {
            $.myControl = { jhtmlarea: this };
            $($.myControl.jhtmlarea.editor.body).keypress(function (e) {
                if ((e.keyCode || e.which) == 13) { //override ENTER KEY to always add a line break
                    if ($.browser.msie) {
                        $('#' + txtEditor).htmlarea('pasteHTML', "<br>");
                        return false;
                    }
                }
                else {
                    if (e.which != 8 && e.which != 0) { //8 is the backspace key
                        var c = String.fromCharCode(e.which);
                        if (e.which == 32) { //32 is the space key
                            $('#' + txtEditor).htmlarea('pasteHTML', '&nbsp;');
                        }
                        else {
                            $('#' + txtEditor).htmlarea('pasteHTML', c);
                        }
                        return false;
                    }
                }
            });
        },

...
}