<!在文章内容显示的地方加入以下代码 > {dede:arclist titlelen='50'} <!文章标题 > <h2><a href="[field:arcurl/]" target="_blank">[field:title/]</a></h2> <!> <p>[field:abstract/]</p> <!文章内容 > <div class="articlecontent"> [field:content/] </div> <!如果需要复制文章内容,加入以下代码 > <div class="copycontent"> <div class="copytext"> <!以下代码用于检测用户是否复制了文章内容,并在控制台输出提示信息 > <script type="text/javascript"> document.addEventListener('copy', function (e) { e.preventDefault(); var selection = window.getSelection(); var content = selection.toString(); var originalSelection = selection.getRangeAt(0); var newSelection = document.createRange(); newSelection.selectNodeContents(document.querySelector('.copytext')); newSelection.collapse(false); var clonedSelection = newSelection.cloneRange(); clonedSelection.deleteContents(); clonedSelection.insertNode(originalSelection); selection.removeAllRanges(); selection.addRange(clonedSelection); var copyContent = clonedSelection.toString(); if (content === copyContent) { console.log('文章内容已复制,请不要非法复制本站内容!'); } originalSelection.collapse(false); selection.removeAllRanges(); selection.addRange(originalSelection); }); </script> <!以下代码用于将文章内容设置为不可选,防止直接复制 > <div contenteditable="false"> [field:content/] </div> </div> </div> {/dede:arclist}
这段代码的主要功能如下:
1、使用{dede:arclist}
标签来遍历文章列表。
2、显示文章标题、摘要和内容。
3、在文章内容下方添加一个不可选的div
元素,其中包含文章的内容。
4、使用JavaScript脚本监听copy
事件,当用户尝试复制内容时,检测是否仅复制了文章内容,并在控制台输出提示信息。
这段代码可能需要根据您的具体模板进行调整,这种方法并不能完全阻止用户复制内容,但它可以作为一种提醒措施,告知用户内容来源。
最新评论
本站CDN与莫名CDN同款、亚太CDN、速度还不错,值得推荐。
感谢推荐我们公司产品、有什么活动会第一时间公布!
我在用这类站群服务器、还可以. 用很多年了。