奥多也网络 发表于 2024-12-18 09:42:58

WordPress 添加复制版权提示

前言今天教大家在别人复制网页内容的时候弹窗提示他人转载表明出处。方法添加如下代码到页脚代码中<script>
document.addEventListener('copy', function(e) {
    e.preventDefault();
    var copyText = window.getSelection().toString();
    var messageWithCredit =copyText;
    e.clipboardData.setData('text', messageWithCredit);

    // 显示复制成功通知
    new Vue({
      data: function () {
            this.$notify({
                title: "复制提示",
                message: "复制成功,请标注转载的出处!",
                position: 'bottom-right',
                offset: 50,
                showClose: true,
                type: "success"
            });
            return { visible: false };
      }
    });
});
</script>

页: [1]
查看完整版本: WordPress 添加复制版权提示