本文链接已复制到剪切板_老谢的空间_百度空间

<script type="text/javascript">
        function CopyText(t)
        {
                //copyToClipboard(document.getElementById(id).value);
                copy(t);
        }
         function copy(text2copy) {
        if (window.clipboardData) {  
          window.clipboardData.setData("Text",text2copy);  
        } else {  
          var flashcopier = 'flashcopier';
             if(!document.getElementById(flashcopier)) {
       var divholder = document.createElement('div');
         divholder.id = flashcopier;
        document.body.appendChild(divholder);
      }
     //document.getElementById(flashcopier).innerHTML = '';
       //var divinfo = '<embed src="clipboard.swf" FlashVars="clipboard='+text2copy+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';//这里是关键
   //document.getElementById(flashcopier).innerHTML = divinfo;
   //alert('Text copied');
   }
   }
        function copyToClipboard(meintext)
    {
     if (window.clipboardData)
       {
       alert("ie");
       // the IE-manier
       window.clipboardData.setData("Text", meintext);
      
       // waarschijnlijk niet de beste manier om Moz/NS te detecteren;
       // het is mij echter onbekend vanaf welke versie dit precies werkt:
       }
       else if (window.netscape)
       {
      
       // dit is belangrijk maar staat nergens duidelijk vermeld:
       // you have to sign the code to enable this, or see notes below
       netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
      
       // maak een interface naar het clipboard
       var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
       if (!clip) return;
       alert("mozilla");
       // maak een transferable
       var trans = Components.classes['@mozilla.org/widget/transferable;1']
                      .createInstance(Components.interfaces.nsITransferable);
       if (!trans) return;
      
       // specificeer wat voor soort data we op willen halen; text in dit geval
       trans.addDataFlavor('text/unicode');
      
       // om de data uit de transferable te halen hebben we 2 nieuwe objecten
       // nodig om het in op te slaan
       var str = new Object();
       var len = new Object();
      
       var str = Components.classes["@mozilla.org/supports-string;1"]
                    .createInstance(Components.interfaces.nsISupportsString);
      
       var copytext=meintext;
      
       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);
      
       }
       alert("Following info was copied to your clipboard:\n\n" + meintext);
       return false;
    }
</script>

<P align=center><INPUT onclick='CopyText("妈妈说再长的文字用JS也能复制出来\nhttp://www.niqzone.com");alert("本文链接已复制到剪切板,内容如下:\n妈妈说再长的文字用JS也能复制出来\nhttp://www.niqzone.com");return false;' type="button" value="复制本文链接,推荐给QQ/MSN上的好友" /></P>



郑重声明:资讯 【本文链接已复制到剪切板_老谢的空间_百度空间】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——