给主题添加复制链接按钮
misaka (150) 6月前

简洁短高兼容性,注:需要ssl证书仅限https链接,标签支持a div button 可以放在任何位置。

功能:

点击后复制链接。

改文字为ok。

在 2 秒后恢复为复制链接。

<a onclick="(i=>{i=document.createElement('input');i.value=location.href;document.body.append(i);i.select();document.execCommand('copy');i.remove();let t=this;t.textContent='ok';setTimeout(()=>t.textContent='复制链接',2000);})()">复制链接</a>
onmouseover="this.style.color='#fff';"onmouseout="this.style.color='';"(自行插入a标签颜色交互适配)

轻鸿弹窗:

<div class="haya-favoriter px-2" style="color: #6c757d;">
<style>
.ntcwin {
    position: fixed;
    z-index: 501;
    left: 50%;
    top: 20%;
    transform: translate(-50%, -50%);
    display: none;
    border-radius: 10px;
    background-color: #333;
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 10px;
    opacity: 0;
    animation: drop 0.5s forwards;
}
@keyframes drop {
    0% { top: 15%; opacity: 0; }
    100% { top: 20%; opacity: 1; }
}
</style>
<a class="btn btn-outline-secondary reward" onmouseover="this.style.color='#fff';"onmouseout="this.style.color='';" onclick="var i=document.createElement('input');i.value=window.location.href;document.body.appendChild(i);i.select();document.execCommand('copy');document.body.removeChild(i);var t=this;t.textContent='ok';setTimeout(function(){t.textContent='分享'},2000);var popup=document.getElementById('ntcwin');popup.style.display='block';setTimeout(function(){popup.style.display='none'},2000)">分享</a>
<div id="ntcwin" class="ntcwin" style="display: none;">
    <table cellspacing="0" cellpadding="0" class="popupcredit">
        <tbody>
            <tr>
                <td class="pc_c">
                    <div class="pc_inner">
                        <span>帖子链接已复制到剪贴板</span>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
</div>
<!--<a class="btn btn-outline-secondary reward" onmouseover="this.style.color='#fff';"onmouseout="this.style.color='';" onclick="(i=>{i=document.createElement('input');i.value=location.href;document.body.append(i);i.select();document.execCommand('copy');i.remove();let t=this;t.textContent='ok';setTimeout(()=>t.textContent='分享',2000);})()">分享</a>--></div>

最新回复 (0)
广告推荐
广告推荐