Reputation: 165
So I've been trying to decode string with .html() function in jQuery and it work really nice except on IE...
Here is the string I have:
ééé\r\nààà
I want this to be:
ééé\r\nààà
and I currently get after .html() with IE:
ééé ààà
So this seems nice on FF and Chrome but on IE all linebreak are removed. I found an article (http://web.student.tuwien.ac.at/~e0226430/innerHtmlQuirk.html) explaining the problem is with .innerHTML used by .html() function...
I'm actually surprised to not found a topic about that. Is there any solution? Maybe do a specific function to decode that on IE?
For more here is the code:
var itemDescription = "ééé\r\nààà";
$('.feeds').find('textarea.description[ifid="' + ifid + '"]').html(itemDescription);
Upvotes: 2
Views: 788
Reputation: 165
Actually one solution I found is to do something like that:
itemDescription = itemDescription.replace(/(\r\n|\r|\n)/g, '________BREAK________');
var decodedDescription = $("<div>").html(itemDescription).text();
decodedDescription = decodedDescription.replace(/________BREAK________/g, '\r\n');
Upvotes: 0
Reputation: 11707
Try This:
var itemDescription = "ééé\\r\\nààà";
Upvotes: 2