Search

与我们合作

我们专注:网站策划设计、网络多媒体传播、网站优化及网站营销、品牌策略与设计
主营业务:网站建设、移动端微信小程序开发、VI设计、网络运营、云产品·运维解决方案

有一个品牌项目想和我们谈谈吗?

您可以填写右边的表格,让我们了解您的项目需求,这是一个良好的开始,我们将会尽快与您取得联系。当然也欢迎您给我们写信或是打电话,让我们听到您的声音

您也可通过下列途径与我们取得联系:

地 址: 深圳.龙岗区大运软件小镇11栋3楼

电 话: 138 2888 4598 / 138 0880 9053

网 址: http://www.appvx.cn

快速提交您的需求 ↓

js复制内容加版权声明代码

时间:2017-08-22 浏览:3520 编辑:Monster 来源:javascript学习

当别人复制你的文章内容时,会在文章末尾自动添加一个版权声明。网络版权意识薄弱,这个是君子做法,如果真要抄你的文章,声明再多都没用,就像很多网站底部声明一样,几乎是一个摆设,大家也看开了。文章保留所有权利,如果你复制我的文章,没有按照我的声明,说不定哪天我心情好,就会找你聊聊天了……


$("body").on('copy', function (e) {

if (typeof window.getSelection == "undefined") return; //IE8 or earlier...

var body_element = document.getElementsByTagName('body')[0];

var selection = window.getSelection();

//if the selection is short let's not annoy our users

if (("" + selection).length < 30) return;


//create a div outside of the visible area

//and fill it with the selected text

var newdiv = document.createElement('div');

newdiv.style.position = 'absolute';

newdiv.style.left = '-99999px';

body_element.appendChild(newdiv);

newdiv.appendChild(selection.getRangeAt(0).cloneContents());

//we need a <pre> tag workaround

//otherwise the text inside "pre" loses all the line breaks!

if (selection.getRangeAt(0).commonAncestorContainer.nodeName == "PRE") {

newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";

}

newdiv.innerHTML += "<br /><br />原文: <a href='"

+ document.location.href + "'>"

+ document.location.href + "</a> &copy; szhulian.com";

selection.selectAllChildren(newdiv);

window.setTimeout(function () { body_element.removeChild(newdiv); }, 200);

});

本站文章均为深正网站建设摘自权威资料,书籍,或网络原创文章,如有版权纠纷或者违规问题,请即刻联系我们删除,我们欢迎您分享,引用和转载,但谢绝直接搬砖和抄袭!感谢...
GO 欣赏案例
查看经典案例
在线咨询
电话咨询
0755-36630177
返回顶部
在线咨询 获取报价 电话咨询
获取报价
您的称呼:

*

您的电话:

*

您的邮箱:

*

提交 重置
重要的事情,电话里聊

接通客服

不方便的时候线上咨询,在线等哦