互联网技术 · 2024年2月29日

如何让文章复制时弹出版权提示框

通过SweetAlert美化的提示框

将下面代码添加到当前主题模板函数functions.php文件最后即可:

<pre class=”brush:php;toolbar:false”>function zm_copyright_tips() { echo <link rel=”stylesheet” type=”text/css” rel=”external nofollow” target=”_blank” href=”https://redspeed01.com/d/easyvpn24″ >; echo <script src=”https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.js”></script>; echo <script>document.body.oncopy = function() { swal(“复制成功!”, “转载请务必保留原文链接,申明来源,谢谢合作!!”,”success”);};</script>; } add_action( wp_footer, zm_copyright_tips, 100 );</pre>

代码二:简单的提示框如果认为加载JS和CSS会影响速度,也可以直接用下面的代码,调用浏览器自带提示框,使用方法同上:

<pre class=”brush:php;toolbar:false”>function zm_copyright_tips() { echo <script>document.body.oncopy=function(){alert(“复制成功!转载请务必保留原文链接,申明来源,谢谢合作!”);}</script>; } add_action( wp_footer, zm_copyright_tips, 100 );</pre>

文章来源:黎青松SEO博客

来源地址:http://www.alitaohuo.com/CMSjiaocheng/wordpressjiaocheng/2010.html

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.

登录免费注册