diff options
-rw-r--r-- | phpBB/styles/prosilver/template/forum_fn.js | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index ad7e3fbc8e..8c619b8f81 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -183,20 +183,40 @@ function selectCode(a) // Get ID of code block var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; - if (document.selection) + // Not IE + if (window.getSelection) { - var r = document.body.createTextRange(); - r.moveToElementText(e); - r.select(); + var s = window.getSelection(); + // Safari + if (s.setBaseAndExtent) + { + s.setBaseAndExtent(e, 0, e, 1); + } + // Firefox and Opera + else + { + var r = document.createRange(); + r.selectNodeContents(e); + s.removeAllRanges(); + s.addRange(r); + } } - else + // Some older browsers + else if (document.getSelection) { - var s = window.getSelection(); + var s = document.getSelection(); var r = document.createRange(); - r.setStartBefore(e); - r.setEndAfter(e); + r.selectNodeContents(e); + s.removeAllRanges(); s.addRange(r); } + // IE + else if (document.selection) + { + var r = document.body.createTextRange(); + r.moveToElementText(e); + r.select(); + } } /** |