Home  >  Article  >  CMS Tutorial  >  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

藏色散人
藏色散人forward
2020-04-30 15:20:442725browse

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 );

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 );

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!

Statement:
This article is reproduced at:zmingcx.com. If there is any infringement, please contact admin@php.cn delete