Copy the following code and put it in single. php. The location can generally be placed under the content code of the article. When others copy the content of the article, the system will attach the copyright information.
The code is as follows: |
Copy code |
<Script type = "text/javascript"> Document. body. oncopy = function (){ Event. returnValue = false; Var t = document. selection. createRange (). text; Var s = "this article comes from <? Php bloginfo ('name');?> <? Php echo get_settings ('Home');?> , Original address: <? Php the_permalink ()?> "; ClipboardData. setData ('text', 'RN '+ t + 'RN' + s + 'RN '); } </Script> |
Note: This method is only applicable to IE browsers. If you need to be compatible with the code instructions of all browsers, see the following example.
As we all know, browsers such as IE, Firefox, and Google are mostly used by webmasters. The popular browsers such as Sogou, and Aoyou are still popular in the 360 s. Is there any code compatible with all browsers? The answer is yes! This JS code is not only applicable to WordPress, but also to a variety of popular open-source programs. The friends who need to use it should remember Mark quickly.
The code is as follows: |
Copy code |
Function addLink (){ Var body_element = document. getElementsByTagName_r ('body') [0]; Var selection; Selection = window. getSelection (); Var pagelink = "this article is transferred from: + document. location. href +" '> "+ document. location. href +" www.111cn.net "; // change this if you want Var copytext = selection + pagelink; Var newdiv = document. createElement_x ('div '); Newdiv. style. position = 'absolute '; Newdiv. style. left = '-99999px '; Body_element.appendChild (newdiv ); Newdiv. innerHTML = copytext; Selection. selectAllChildren (newdiv ); Window. setTimeout (function (){ Body_element.removeChild (newdiv ); }, 0 ); } Document. oncopy = addLink; |
Note: put it in footer. php for the whole site, and put it in single. php for the article page only. You can modify the text in the code on your own.