Home > CMS Tutorial > WordPress > How to implement the copyright prompt box that pops up when copying the article content

How to implement the copyright prompt box that pops up when copying the article content

藏色散人
Release: 2020-04-30 15:20:44
forward
2886 people have browsed it

The following column WordPress Website Building Tutorial will introduce to you the implementation method of copying the content of the article to pop up the copyright prompt box. I hope it will be helpful to friends in need!

How to implement the copyright prompt box that pops up when copying the article content

Code 1

Beautiful prompt box through SweetAlert

Add the following code to the end of the current theme template function functions.php file. Can:

function zm_copyright_tips() {
 echo &#39;<link rel="stylesheet" type="text/css" rel="external nofollow" target="_blank" href="https://zmingcx.com/wp-content/themes/begin/go.php?url=aHR0cHM6Ly9jZG4uYm9vdGNzcy5jb20vc3dlZXRhbGVydC8xLjEuMy9zd2VldGFsZXJ0Lm1pbi5jc3M=" >&#39;;
 echo &#39;<script src="https://cdn.bootcss.com/sweetalert/1.1.3/sweetalert.min.js"></script>&#39;;
 echo &#39;<script>document.body.oncopy = function() { swal("复制成功!", "转载请务必保留原文链接,申明来源,谢谢合作!!","success");};</script>&#39;;
}
add_action( &#39;wp_footer&#39;, &#39;zm_copyright_tips&#39;, 100 );
Copy after login

The effect is as shown:

How to implement the copyright prompt box that pops up when copying the article content

##Code 2:

Simple prompt box

If you think that loading JS and CSS will affect the speed, you can also use the following code directly to call the browser's own prompt box. The usage method is the same as above:

function zm_copyright_tips() {
echo &#39;<script>document.body.oncopy=function(){alert("复制成功!转载请务必保留原文链接,申明来源,谢谢合作!");}</script>&#39;;
}
add_action( &#39;wp_footer&#39;, &#39;zm_copyright_tips&#39;, 100 );
Copy after login
The effect is as shown in the figure:

How to implement the copyright prompt box that pops up when copying the article content

The above code directly calls the public library from the external link. You can also download the JS and CSS from the external link to the local to further beautify and modify the style.

For more

WordPress Tips articles, please visit the WordPress column!

The above is the detailed content of How to implement the copyright prompt box that pops up when copying the article content. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:zmingcx.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template