Hi All,

I'm selecting text from an iframe using getSelection(). It reads everything but the tabs '\t'.

You could try this code (it will require jQuery)

$('#click').click(function(){
    var range = window.getSelection().getRangeAt(0);
    var selectionContents = range.extractContents();
    var span = document.createElement("span");
    span.style.color = "red";
    span.appendChild(selectionContents);
    range.insertNode(span);
    
    
    alert(range);
    
});​

<p>Some text</p>
<button id="click">Click</button>​

Hi thanks!

I need to know the Caret Character Offset, and I need the tabs and \n \r to know the exact position of the selection

I have a text kept in MySQL database. I need to do certain operations in the database. And the data is displayed on an iframe. So I when I select text in the iframe the position doesn't correspond to the position in the data base. I think it might be the \r that is not recognised.. or some \t or \n, but whenever there is a newline the position doesn't match

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.