abstrait:工作原理利用一個(gè)透明的 Flash ,讓其漂浮在按鈕之上,這樣其實(shí)點(diǎn)擊的不是按鈕而是 Flash ,也就可以使用 Flash 的復(fù)制功能了<script src="js/jquery/jquery-1.8.0.min.js"></script> <script type="text/javascript"&n
工作原理
利用一個(gè)透明的 Flash ,讓其漂浮在按鈕之上,這樣其實(shí)點(diǎn)擊的不是按鈕而是 Flash ,也就可以使用 Flash 的復(fù)制功能了
<script src="js/jquery/jquery-1.8.0.min.js"></script> <script type="text/javascript" src="js/jquery-zclip/jquery.zclip.js"></script> <script type="text/javascript"> $(function(){ var $copyBtn = $('#copy-video-link'); copyVideoLink($copyBtn); }); //復(fù)制視頻網(wǎng)址 function copyVideoLink($that){ //設(shè)置flash動(dòng)畫 ZeroClipboard.setMoviePath("js/jquery-zclip/ZeroClipboard.swf"); var clip = new ZeroClipboard.Client(); // 設(shè)置鼠標(biāo)為手型 clip.setHandCursor(true); //設(shè)置要復(fù)制的文本 clip.setText($that.attr("data-href")); clip.glue($that.attr("id")); //復(fù)制完成后的監(jiān)聽事件 clip.addEventListener('complete', function (client, text) { alert("你已經(jīng)復(fù)制成功" + text); // 復(fù)制一次后,hide()使復(fù)制按鈕失效,防止重復(fù)計(jì)算使用次數(shù) }); } </script>
更多關(guān)于jquery.zclip輕量級(jí)復(fù)制失效問(wèn)題請(qǐng)關(guān)注PHP中文網(wǎng)(ipnx.cn)其他文章!