Here is HTML code. It supposed to select all text in "Container" div
<B onclick="SelectText(document.getElementById('Container'));">select all text</B>
<Div id="Container">
<Div>123456</Div>
<Div>123456</Div>
<Div onclick="SelectText();">123456</Div>
</Div>
here is JS code of the SelectText() function
function SelectText(target){
if(target==null){
var e = window.event || e;
if (!e) var e = window.event;
var target=e.target || e.srcElement;
}
var rng, sel;
if ( document.createRange ) {
rng = document.createRange();
rng.selectNode( target );
sel = window.getSelection();
sel.removeAllRanges();
sel.addRange( rng );
} else {
var rng = document.body.createTextRange();
rng.moveToElementText( target );
rng.select();
}
}
Problem is that in Opera 12.02 when "select all text" is clicked, all text seems like selected, but it's not selected (I can't rightclick it and copy).
(terrific, but IE works fine with it)
Why not in Opera?!!! And what can I do to make Opera 12.02 believe that all text in "Container" is selected?