emlog简单js实现复制弹窗加文字版权
<script type="text/javascript">$("body").bind('copy', function (e){if(typeof window.getSelection == "undefined") return;var body_element = document.getElementsByTagName('body')[0];var selection = window.getSelection();if (("" + selection).length < 30) return;var newdiv = document.createElement('div');newdiv.style.position = 'absolute';newdiv.style.left = '-99999px';body_element.appendChild(newdiv);newdiv.appendChild(selection.getRangeAt(0).cloneContents());if(selection.getRangeAt(0).commonAncestorContainer.nodeName == "PRE"){newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";} newdiv.innerHTML += "来自吾爱搜-原文地址:" + document.location.href + ""; selection.selectAllChildren(newdiv);window.setTimeout(function(){body_element.removeChild(newdiv);},200);});function warning(){ if(navigator.userAgent.indexOf("MSIE")>0) { art.dialog.alert('我复制成功!若要转载请务必保留原文链接,申明来源,谢谢合作!'); } else { alert("复制成功!若要转载请务必保留原文链接,申明来源,谢谢合作!"); }} document.body.oncopy=function(){warning();}</script>
请将上面代码插入你网站的footer或者head文件里面。即可实现复制弹窗提醒加文字版权。。