IT/컴퓨터사용2011. 8. 20. 23:46

<script language='javascript'>
 function fncCopy()
 {
     if (window.clipboardData)
     {
         window.clipboardData.setData('Text', '복사할 내용');
         alert('복사했습니다.');
         self.close();
     }
     else if (window.netscape)
     {
         if(navigator.userAgent.indexOf('Firefox')>0)
         {
             netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
             var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
             if (!clip) return;
             var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
             if (!trans) return;
             trans.addDataFlavor('text/unicode');
             var str = new Object();
             var len = new Object();
            var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
            var copytext = '복사할 내용';
            str.data=copytext;
            trans.setTransferData("text/unicode",str,copytext.length*2);
            var clipid=Components.interfaces.nsIClipboard;
            if (!clip) return false;
            clip.setData(trans,null,clipid.kGlobalClipboard);
        }
    }
}
</script>





링크되었던 웹페이지를 열면. 지정한 문자를 클립보드로 복사한뒤.
열었던 웹페이지를 닫도록 하는 소스입니다.
Posted by 차승준 Xcode

댓글을 달아 주세요