zoukankan      html  css  js  c++  java
  • 网页复制内容追加到剪切板

    function addLink() {
                let body_element = document.body;
                let selection = window.getSelection();
                let locationHref = document.location.href;
                let appendLink = "
    
     原文出自[ ushowtime ] 转载请保留原文链接: <a href='" + locationHref + "'>" + locationHref + "</a>";
                if (window.clipboardData) { // Internet Explorer
                    let copytext = selection + appendLink;
                    window.clipboardData.setData("Text", copytext);
                    return false;
                } else {
                    let copytext = selection + appendLink;
                    let newdiv = document.createElement('div');
                    newdiv.style.position = 'absolute';
                    newdiv.style.left = '-99999px';
                    body_element.appendChild(newdiv);
                    newdiv.innerHTML = copytext;
                    selection.selectAllChildren(newdiv);
                    window.setTimeout(function() {
                        body_element.removeChild(newdiv);
                    }, 0);
                }
            }
  • 相关阅读:
    Ubuntu 18.04 初始化(server版本 )
    named主从环境部署
    CentOS 源码安装svn
    端口状态
    进程状态
    top命令详解
    gitlab部署
    day16
    day15
    day14
  • 原文地址:https://www.cnblogs.com/ushowtime/p/14878127.html
Copyright © 2011-2022 走看看