Add select content to code box

View previous topic View next topic Go down

Add select content to code box Empty Add select content to code box

Post by _Twisted_Mods_ 1/24/2015, 6:38 pm

_Twisted_Mods_
_Twisted_Mods_
Founder
Founder

Posts : 101
Reputation : 3
Birthday : 1986-08-05
Join date : 2014-10-03
Age : 37
Location : USA

[script=Your choice=in the topics]
Code:
$(function(){
$('.codebox dt').append(' <a href="#" onclick="selectCode(this); return false;" title="Select all the content" class="code-a" style="float:right;"> Select Content </a> ');   
function selectCode(a){
    var e=a.parentNode.parentNode.getElementsByTagName('CODE')[0];
    if(window.getSelection){
        var s=window.getSelection();
        if(s.setBaseAndExtent){
            s.setBaseAndExtent(e,0,e,e.innerText.length-1)
        }else{
            if(window.opera&&e.innerHTML.substring(e.innerHTML.length-4)=='<BR>'){
                e.innerHTML=e.innerHTML+' '
            }
            var r=document.createRange();
            r.selectNodeContents(e);
            s.removeAllRanges();
            s.addRange(r)}
    }else if(document.getSelection){
                var s=document.getSelection();
        var r=document.createRange();
        r.selectNodeContents(e);
        s.removeAllRanges();
        s.addRange(r)}else if(document.selection){var r=document.body.createTextRange();
                                                                                            r.moveToElementText(e);
                                                                                            r.select()}}if(text){}else{
                                                                                                var text='Selecionar todos'
                                                                                                }

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum