복사 스크립트

<script type="text/javascript">
autosize($('textarea'));
function CopyToClipboard ( tagToCopy, textarea ){ 
        textarea.parentNode.style.display = "block"; 
        var textToClipboard = ""; 
        if ( "value" in tagToCopy ){    textToClipboard = tagToCopy.value;    } 
        else {    textToClipboard = ( tagToCopy.innerText ) ? tagToCopy.innerText : tagToCopy.textContent;    } 
        var success = false; 
        if ( window.clipboardData ){ 
                window.clipboardData.setData ( "Text", textToClipboard ); 
                success = true; 
        } 
        else { 
                textarea.value = textToClipboard; 
                var rangeToSelect = document.createRange(); 
                rangeToSelect.selectNodeContents( textarea ); 
                var selection = window.getSelection(); 
                selection.removeAllRanges(); 
                selection.addRange( rangeToSelect ); 
                success = true; 
                try { 
                    if ( window.netscape && (netscape.security && netscape.security.PrivilegeManager) ){ 
                        netscape.security.PrivilegeManager.enablePrivilege( "UniversalXPConnect" ); 
                    } 
                    textarea.select(); 
                    success = document.execCommand( "cut", false, null ); 
                } 
                catch ( error ){ 
                    success = false; 
                    console.log( error ); 
                } 
        } 
        textarea.parentNode.style.display = "none"; 
        textarea.value = ""; 
        if ( success ){ alert( ' 클립보드에 복사되었습니다. n "Ctrl+v"를 사용하여 원하는 곳에 붙여넣기 하세요. ' ); } 
        else {    alert( " 복사하지 못했습니다. " );    } 
        /* 
        if ( success ){ alert( ' The texts were copied to clipboard. nn Paste it, using "Ctrl + v". n ' );    } 
        else {    alert( " It was failed to copy. n " );    } 
        */ 
} 
</script>
<div style="display: none;"><textarea id="myClipboard"></textarea></div>
<textarea onclick="CopyToClipboard( this, myClipboard )" style="background-color:#fefefe;" rows="5" cols="70">여기에 입력</textarea>

댓글 등록하기