In an empty Asp.Net project I have the following code:
I am using TextRange.HtmlText in IE 8 to retrieve a user's text selection in a DIV element. However, for some reason the selected html contains \r\n even though there are no line break characters in the original text. Does anyone know why this is happening?
The same behavior is not observed if I use the text property instead.
<script type="text/javascript">
function OkClick() {
var TextRange = document.selection.createRange();
var SelectedText = TextRange.htmlText;
}
</script>
<div>
This is a test with a long line of text on a single line with no line breaks.Why is there a line break returned from htmlText on the TextRange object
</div>
<button onclick="OkClick()">OK</button>
The following is assigned to my SelectedText variable: As you can see there is a line break after the word "Why"
This is a test with a long line of text on a single line with no line breaks.Why \r\nis there a line break returned from htmlText on the TextRange object