Advertisement:

Author Topic: selec text in a code box dont work with new chrome broser...  (Read 4265 times)

Offline katze49

  • Newbie
  • *
  • Posts: 1
selec text in a code box dont work with new chrome broser...
« on: October 30, 2018, 04:26:08 PM »
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:
Code: [Select]
// 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 ...