<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
我是内容
</body>
<script>
function addLink() {
var body_element = document.body;
var selection;
var blogName = '你的网站名称';
selection = window.getSelection() ? window.getSelection() : document.selection.createRange().text;
if (window.clipboardData) {
var pagelink ="<br/>---------------------<br/>本文来源:"+blogName+"<br/>原文链接:"+document.location.href+"";
var copyText = selection + pagelink;
window.clipboardData.setData ("Text", copyText);
return false;
} else {
var pagelink = "<br/>---------------------<br/>本文来源:"+blogName+"<br/>原文链接:"+document.location.href+"";
var copyText = selection + pagelink;
var 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);
}
}
document.oncopy = addLink;
</script>
</html>
JS复制内容自动添加版权信息
最新推荐文章于 2023-10-11 09:29:51 发布