官网:
https://clipboardjs.com/
样式:单选复制和全选复制
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Document</title>
</head>
<body><textarea id="link_result" name="result" value="" style="position: absolute;z-index: -1;"></textarea><div class="btn btn-danger" id="link_copy_check" data-clipboard-action="copy" data-clipboard-target="#link_result">批量获取推广链接</div><form id="getStart" name="getStart"><table class="table table-striped table-bordered table-hover responsive"><thead><tr><td width="5%"><input type="checkbox" name="choose_all" id="ischeckAll" onclick="isCheck()">全选</td><td>小说名称</td><td>链接</td> </tr></thead><tbody><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72349" value="偷偷爱你 http://t.cn/EvVnSXV"></td><td> 偷偷爱你 <span class="state is_new_state ">新书 </span> </td><td><div class="shorturl_72349"><span class="col-xs-12 col-sm-6 link_72349 shorturl" style="overflow: hidden;text-overflow: ellipsis;">偷偷爱你 http://t.cn/EvVnSXV</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72349" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzQ5LzQxOC92Lzg4" data-name="偷偷爱你" value="偷偷爱你 http://t.cn/EvVnSXV" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72349">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72357" value="绝品男保姆 http://t.cn/EvVnbls"></td><td> 绝品男保姆 <span class="state is_new_state ">新书 </span> </td><td><div class="shorturl_72357"><span class="col-xs-12 col-sm-6 link_72357 shorturl" style="overflow: hidden;text-overflow: ellipsis;">绝品男保姆 http://t.cn/EvVnbls</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72357" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzU3LzQxOC92Lzg4" data-name="绝品男保姆" value="绝品男保姆 http://t.cn/EvVnbls" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72357">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72350" value="醉人之香 http://t.cn/EvVnblB"></td><td> 醉人之香 <span class="state is_new_state ">新书 </span> </td><td><div class="shorturl_72350"><span class="col-xs-12 col-sm-6 link_72350 shorturl" style="overflow: hidden;text-overflow: ellipsis;">醉人之香 http://t.cn/EvVnblB</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72350" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzUwLzQxOC92Lzg4" data-name="醉人之香" value="醉人之香 http://t.cn/EvVnblB" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72350">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72337" value="都市高手游花丛 http://t.cn/EvVnblQ"></td><td> 都市高手游花丛 <span class="state is_new_state ">新书 </span> </td><td><div class="shorturl_72337"><span class="col-xs-12 col-sm-6 link_72337 shorturl" style="overflow: hidden;text-overflow: ellipsis;">都市高手游花丛 http://t.cn/EvVnblQ</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72337" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzM3LzQxOC92Lzg4" data-name="都市高手游花丛" value="都市高手游花丛 http://t.cn/EvVnblQ" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72337">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72330" value="和后妈一起的日子 http://t.cn/EvVnbjG"></td><td> 和后妈一起的日子 <span class="state is_new_state ">新书 </span> </td><td><div class="shorturl_72330"><span class="col-xs-12 col-sm-6 link_72330 shorturl" style="overflow: hidden;text-overflow: ellipsis;">和后妈一起的日子 http://t.cn/EvVnbjG</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72330" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzMwLzQxOC92Lzg4" data-name="和后妈一起的日子" value="和后妈一起的日子 http://t.cn/EvVnbjG" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72330">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72380" value="医道圣眼 http://t.cn/EvSIGJn"></td><td> 医道圣眼 </td><td><div class="shorturl_72380"><span class="col-xs-12 col-sm-6 link_72380 shorturl" style="overflow: hidden;text-overflow: ellipsis;">医道圣眼 http://t.cn/EvSIGJn</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72380" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzgwLzQxOC92Lzg4" data-name="医道圣眼" value="医道圣眼 http://t.cn/EvSIGJn" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72380">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72379" value="荒唐日记 http://t.cn/EvSIGaA"></td><td> 荒唐日记 </td><td><div class="shorturl_72379"><span class="col-xs-12 col-sm-6 link_72379 shorturl" style="overflow: hidden;text-overflow: ellipsis;">荒唐日记 http://t.cn/EvSIGaA</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72379" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzc5LzQxOC92Lzg4" data-name="荒唐日记" value="荒唐日记 http://t.cn/EvSIGaA" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72379">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72347" value="乡女似水 http://t.cn/EvVnbY4"></td><td> 乡女似水 </td><td><div class="shorturl_72347"><span class="col-xs-12 col-sm-6 link_72347 shorturl" style="overflow: hidden;text-overflow: ellipsis;">乡女似水 http://t.cn/EvVnbY4</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72347" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzQ3LzQxOC92Lzg4" data-name="乡女似水" value="乡女似水 http://t.cn/EvVnbY4" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72347">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72339" value="佳人如玉 http://t.cn/EvVnbEn"></td><td> 佳人如玉 </td><td><div class="shorturl_72339"><span class="col-xs-12 col-sm-6 link_72339 shorturl" style="overflow: hidden;text-overflow: ellipsis;">佳人如玉 http://t.cn/EvVnbEn</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72339" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzM5LzQxOC92Lzg4" data-name="佳人如玉" value="佳人如玉 http://t.cn/EvVnbEn" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72339">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72322" value="村中女人香 http://t.cn/EvVnb3U"></td><td> 村中女人香 </td><td><div class="shorturl_72322"><span class="col-xs-12 col-sm-6 link_72322 shorturl" style="overflow: hidden;text-overflow: ellipsis;">村中女人香 http://t.cn/EvVnb3U</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72322" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzIyLzQxOC92Lzg4" data-name="村中女人香" value="村中女人香 http://t.cn/EvVnb3U" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72322">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72311" value="我的红粉佳人 http://t.cn/EvVnbu3"></td><td> 我的红粉佳人 </td><td><div class="shorturl_72311"><span class="col-xs-12 col-sm-6 link_72311 shorturl" style="overflow: hidden;text-overflow: ellipsis;">我的红粉佳人 http://t.cn/EvVnbu3</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72311" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzExLzQxOC92Lzg4" data-name="我的红粉佳人" value="我的红粉佳人 http://t.cn/EvVnbu3" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72311">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72307" value="小村野花香 http://t.cn/EvVnbul"></td><td> 小村野花香 </td><td><div class="shorturl_72307"><span class="col-xs-12 col-sm-6 link_72307 shorturl" style="overflow: hidden;text-overflow: ellipsis;">小村野花香 http://t.cn/EvVnbul</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72307" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMzA3LzQxOC92Lzg4" data-name="小村野花香" value="小村野花香 http://t.cn/EvVnbul" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72307">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72155" value="乡野春风 http://t.cn/EvVnb3u"></td><td> 乡野春风 </td><td><div class="shorturl_72155"><span class="col-xs-12 col-sm-6 link_72155 shorturl" style="overflow: hidden;text-overflow: ellipsis;">乡野春风 http://t.cn/EvVnb3u</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72155" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMTU1LzQxOC92Lzg4" data-name="乡野春风" value="乡野春风 http://t.cn/EvVnb3u" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72155">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_72144" value="绝品盲技师 http://t.cn/EvVnbes"></td><td> 绝品盲技师 </td><td><div class="shorturl_72144"><span class="col-xs-12 col-sm-6 link_72144 shorturl" style="overflow: hidden;text-overflow: ellipsis;">绝品盲技师 http://t.cn/EvVnbes</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_72144" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcyMTQ0LzQxOC92Lzg4" data-name="绝品盲技师" value="绝品盲技师 http://t.cn/EvVnbes" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_72144">复制</div></div></td></tr><tr class="referral-link-item"><td><input type="checkbox" name="choose_id" onclick="getChecked()" class="link2_71951" value="妙手偷香 http://t.cn/EvVnbkw"></td><td> 妙手偷香 </td><td><div class="shorturl_71951"><span class="col-xs-12 col-sm-6 link_71951 shorturl" style="overflow: hidden;text-overflow: ellipsis;">妙手偷香 http://t.cn/EvVnbkw</span><input type="text" class="col-xs-12 col-sm-6 copy_input_46784 shorturl_v" id="link_71951" data-val="aHR0cHM6Ly9wYXNzcG9ydC56aGFuLnNvaHUuY29tL3Bhc3Nwb3J0L3NvaHUvbG9naW4tanVtcHRvP2NhbGxiYWNrPWh0dHA6Ly93d3cuamluZ2Rpd2VpLmNvbS9iLzcxOTUxLzQxOC92Lzg4" data-name="妙手偷香" value="妙手偷香 http://t.cn/EvVnbkw" style="position: absolute;z-index: -1;" data-short="true"><div class="btn btn-copy promote_list_copy btn-primary" data-clipboard-action="copy" data-clipboard-target="#link_71951">复制</div></div></td></tr> </tbody></table></form>
<script type="text/javascript" src="/Public/static/js/clipboard.min.js"></script>
<script src="/Public/layer/layer.js" type="text/javascript"></script>
<script>/*判断浏览器版本*/var browser = {versions:function(){var u = navigator.userAgent;return {QQ:u.indexOf('MQQBrowser') > -1,UC:u.indexOf('UCBrowser') > -1,trident: u.indexOf('Trident') > -1, //IE内核
presto: u.indexOf('Presto') > -1, //opera内核
webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
mobile: !!u.match(/AppleWebKit.*Mobile.*/)||!!u.match(/AppleWebKit/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
};}(),language:(navigator.browserLanguage || navigator.language).toLowerCase()}// var isIE = browser.versions.android && browser.versions.QQ;var isIE = (browser.versions.android && browser.versions.QQ) || (browser.versions.android && browser.versions.UC);/**//*点击复制单个*/var clipboard = new Clipboard('.promote_list_copy');clipboard.on('success', function (e) {e.clearSelection();});clipboard.on('error', function (e) {console.log('复制失败,请手动选择复制');});$(".promote_list_copy").on("click", function (event) {var link_one = $(this).prev($("input[type=text]")).val();document.execCommand("Copy");// if(isIE !== true){
promte('1');// } var event = event || window.event;event.preventDefault(); window.event.returnValue = false; });/*点击复制全部*/var oCheckAll = new Clipboard('#link_copy_check');oCheckAll.on('success', function (e) {e.clearSelection();});oCheckAll.on('error', function (e) {console.log('复制失败,请手动选择复制');});$("#link_copy_check").on("click", function (event) {var iCheckLen = $('input[name=choose_id]:checked').length;console.log(iCheckLen);if(iCheckLen == 0){promte('0');}else{var txt = $(this).prev($("input[type=text]")).val();// if(isIE !== true){
promte('1');// }
}document.execCommand("Copy"); var event = event || window.event;event.preventDefault(); window.event.returnValue = false; });/*是否全选*/function isCheck(){var obj = document.getElementById('ischeckAll');if(obj.checked==false) {clearAll('choose_id');getChecked();} else { checkAll('choose_id');getChecked(); }}//全选function checkAll(name) {var el = document.getElementsByTagName('input');var len = el.length;for(var i=0; i<len; i++) {if((el[i].type=="checkbox") && (el[i].name==name)) {el[i].checked = true;}}}//反选function clearAll(name) {var el = document.getElementsByTagName('input');var len = el.length;for(var i=0; i<len; i++) {if((el[i].type=="checkbox") && (el[i].name==name)) {el[i].checked = false;}}}//获取checkbox已选项function getChecked() {var result = '';var form = document.getElementById('getStart');if(typeof form.choose_id.length != 'undefined') {for(var i=0; i<form.choose_id.length; i++) {if(form.choose_id[i].checked) {result += form.choose_id[i].value + " \r\n ";}}} else {if(form.choose_id_type.checked) {result += form.choose_id_type.value + ' ';}}if(result == '') {document.getElementById('link_result').value ='';} else {document.getElementById('link_result').value = result;}}/*提示消息*/function promte(info){var msg = info == '1' ? '链接已经复制到粘贴板,请直接粘贴!!' : '您还没有选中要复制的内容!!';layer.open({type: 0,title: '友情提示:',content: msg,time: 2000,});}/*** 获取短连接*/function shorturl(i,is_bool){var is_bool = is_bool?is_bool:false;var user_count = $('.shorturl_v').length;if(user_count <= i){checkShort();return false;}var obj = $('.shorturl_v').eq(i);var longUrl = obj.attr('data-val');var name = obj.attr('data-name');var url = 'http://short.reakingad.com/short.php?url='+longUrl+'&i='+i+'&callback=?';$.getJSON(url,function(a){if(a.status == 1){var url_val = name +' '+a.url_short;obj.attr('value' , url_val);obj.attr('data-short' , true);obj.closest('td').find('.shorturl').html(url_val);obj.closest('tr').find('input[type=checkbox]').attr('value' , url_val);}else{shorturl(a.i,true);}})if(!is_bool){i++;shorturl(i);}}shorturl(0);function checkShort(){var is_bool = true;$('.shorturl_v').map(function(){if($(this).attr('data-short')+'' == 'undefined'){is_bool = false;}})if(is_bool){$('.promote_list_copy').removeClass('hide');$('#link_copy_check').removeClass('hide');}else{setTimeout(checkShort,1000);}} </script>
</body>
</html>