zoukankan      html  css  js  c++  java
  • [转载]js复制内容加版权声明代码

    转自:https://www.cnblogs.com/zdz8207/p/js-oncopy.html

     1   var ua = navigator.userAgent.toLowerCase();
     2     if( window.ActiveXObject ){
     3         document.body.oncopy = function(){
     4             event.returnValue = false;
     5             var t=document.selection.createRange().text;
     6             var s=" 原文链接:"+location.href;
     7             clipboardData.setData('Text',t+'
    '+s);
     8         };
     9     }else{
    10         function addLink(){
    11             var body_element = document.getElementsByTagName('body')[0];
    12             var selection;
    13             selection = window.getSelection();
    14             var pagelink = " 原文链接:"+location.href;
    15             var copytext = selection + pagelink;
    16             var newdiv = document.createElement('div');
    17             newdiv.style.position='absolute';
    18             newdiv.style.left='-99999px';
    19             body_element.appendChild(newdiv);
    20             newdiv.innerHTML = copytext;
    21             selection.selectAllChildren(newdiv);
    22             window.setTimeout(function(){body_element.removeChild(newdiv);},0);
    23         }
    24         document.oncopy = addLink;
    25     }
  • 相关阅读:
    Sqli-labs less 12
    Sqli-labs less 13
    Sqli-labs less 14
    Python3之collections模块
    Python3之 contextlib
    Python3之sqlalchemy
    Python3之RabbitMQ
    Python3之redis使用
    Python3之Memcache使用
    python自动化开发学习 进程, 线程, 协程
  • 原文地址:https://www.cnblogs.com/ss977/p/8464359.html
Copyright © 2011-2022 走看看