Thanks to wescrow and Sohnee for pointing me in the right direction why this is happening.
In IE7 and IE8 using code
$('#contentTextOriginal').html(); or $('#contentTextOriginal').text();
It will mean that IE7 and IE8 remove any formatting, extra spaces / returns regardless of whether the element is set correctly, for example. pre, white-space css.
The only way I could get around this is to use the function
document.getElementById('contentTextOriginal').innerText;
But this innerText is not supported in any other standard FF / Chrome browser.
So, I have hasd to set some JS condition for using inner text for IE8 and below, and jQuery for everything else.
Something like this will work.
<script type="text/javascript"> var i_am_old_ie = false; </script> <!--[if LT IE 8]> <script type="text/javascript"> i_am_old_ie = true; </script> <![endif]--> if (i_am_old_ie) { textToEdit = document.getElementById('contentTextOriginal' + id).innerText; } else { textToEdit = $('#contentTextOriginal' + id).html(); }
I hate using conditional scripts, if someone could think of something else, I would be very grateful.
source share