selec text in a code box dont work with new chrome broser...

Started by katze49, October 30, 2018, 04:26:08 PM

Previous topic - Next topic

katze49

As above describe ...

And a fix for this problem ... works with all modern browser (FF, Opera, Edge, Chrome 70 and Chrome Canary)

Repace the function smfSelectText with this:

// Get the text in a code tag.
function smfSelectText(oCurElement, bActOnElement)
{
// The place we're looking for is one div up, and next door - if it's auto detect.
if (typeof(bActOnElement) == 'boolean' && bActOnElement)
var oCodeArea = document.getElementById(oCurElement);
else
var oCodeArea = oCurElement.parentNode.nextSibling;

if (typeof(oCodeArea) != 'object' || oCodeArea == null)
return false;

if (window.getSelection && document.createRange) {
sel = window.getSelection();
range = document.createRange();
range.selectNodeContents(oCodeArea);
sel.removeAllRanges();
sel.addRange(range);
}
else if (document.selection && document.body.createTextRange) {
textRange = document.body.createTextRange();
textRange.moveToElementText(oCodeArea);
textRange.select();
}
return false;
}


Thanks for reading ...

Advertisement: