Appendix/컴퓨터 이야기

복사시 출처 출력하기

구름팡팡 2008. 7. 9. 13:07
내용을 복사해서 붙여넣기하면 자동으로 맨 아래 출처가 입력됩니다.
복사해서 메모장 같은데 붙여넣기 해보세요.
저는 이 내용을 skin.html에 넣어 두었습니다.

<script>
    function contents_cp()
    {
        if (window.event)
        {
            window.event.returnValue = true;
            window.setTimeout('attach_kinref()', 25);
        }
    }
    function attach_kinref()
    {
        if (window.clipboardData) // IE
        {
            // get data from clipboard
            var txt = window.clipboardData.getData('Text');
            // attach the source at the end of text
            txt = txt + '\r\n(출처 : \''+title_js_var+'\' - http://psicopompus.tistory.com)\r\n';
            // set data to clibboard
            var result = window.clipboardData.setData('Text', txt);
        }
    }
</script>
<script> var title_js_var = "Le antiche cronache del 1985"; </script>
<div id='contents_area' onCopy='javascript:contents_cp();'>
내용을 복사해서 붙여넣기하면 자동으로 맨 아래 출처가 입력됩니다.
복사해서 메모장 같은데 붙여넣기 해보세요.
</div>