WordPress复制后自动加版权声明

有时候为了避免别的网站无版权复制就发出,我们难免会要用到一些手段,就...比如是这个。

将以下代码加到header.php中即可:

<script ="text/javascript">下面的代码放这里</script>

然后是代码:

function addLink() {
    var selection = window.getSelection();
    pagelink = ". 原文出自[好源码] 转载请保留原文链接:" + document.location.href;
    copytext = selection + pagelink;
    newdiv = document.createElement('div');
    newdiv.style.position = 'absolute';
    newdiv.style.left = '-99999px';
    document.body.appendChild(newdiv);
    newdiv.innerHTML = copytext;
    selection.selectAllChildren(newdiv);
    window.setTimeout(function () {
        document.body.removeChild(newdiv);
    }, 100);
}
document.oncopy = addLink;

PS:好源码可以改成你的网站名称。

本文由 好源码 作者:好源码站长 发表,其版权均为 好源码 所有,文章内容系作者个人观点,不代表 好源码 对观点赞同或支持。如需转载,请注明文章来源。
2
好源码站长

发表评论


Fatal error: Uncaught exception 'JSMin_UnterminatedStringException' with message 'JSMin: Unterminated String at byte 478: ",' in /www/wwwroot/www.0598128.com/wp-content/plugins/wp-rocket/min/lib/JSMin.php:203 Stack trace: #0 /www/wwwroot/www.0598128.com/wp-content/plugins/wp-rocket/min/lib/JSMin.php(145): JSMin->action(1) #1 /www/wwwroot/www.0598128.com/wp-content/plugins/wp-rocket/min/lib/JSMin.php(84): JSMin->min() #2 /www/wwwroot/www.0598128.com/wp-content/plugins/wp-rocket/inc/front/minify.php(230): JSMin::minify('\n {\n ...') #3 [internal function]: rocket_minify_inline_js('\n {\n ...') #4 /www/wwwroot/www.0598128.com/wp-content/plugins/wp-rocket/min/lib/Minify/HTML.php(243): call_user_func('rocket_minify_i...', '\n {\n ...') #5 [internal function]: Minify_HTML->_removeScriptCB(Array) #6 /www/wwwroot/www.0598128.com/wp-content/plugins/wp-rocket/min/lib/Minify/HTML.php(105): preg_replace_callback('/(\\s*)<script(\\...', Array, '<!doctype html>...') #7 /www/wwwroot/www.0598128.com/wp-conte in /www/wwwroot/www.0598128.com/wp-content/plugins/wp-rocket/min/lib/JSMin.php on line 203