Now many webmasters want others to copy their own website articles to bring a link, but this is just an idealized process where almost everyone will delete the source, the copyright information is automatically added to the end of the article. Below I want to organize a lot of examples randomly added to the copyright in the article.
Example 1:
After adding the file, you only need to copy the content of the page and add a url of the current file at random. However, unfortunately, many webmasters directly Delete the subsequent file with the copyright.
| The Code is as follows: |
Copy code |
|
Document. body. oncopy = function (){
SetTimeout (function ()
{
Var text = clipboardData. getData ("text ");
If (text ){
For more details about text = text + "rn, see:" + location. href;
ClipboardData. setData ("text", text );
}
}, 100)
} |
Example 2,After the code above is improved, we add a url in an indefinite location based on the content length. This method has a slight effect.
| The Code is as follows: |
Copy code |
|
Function left (mainStr, lngLen ){
If (lngLen> 0) {return mainStr. substring (0, lngLen )}
Else {return null}
}
Function right (mainStr, lngLen ){
If (mainStr. length-lngLen> = 0 & mainStr. length> = 0 & mainStr. length-lngLen <= mainStr. length ){
Return mainStr. substring (mainStr. length-lngLen, mainStr. length )}
Else {return null}
}
Document. body. oncopy = function ()
{
SetTimeout (function (){
Var d = clipboardData. getData ("text ");
Var LenStr = d. length;
Var LeftNum = Math. floor (LenStr/2 );
Var RightNum = LenStr-LeftNum;
Var AddStr = "(www. bKjia. c0m )";
Var AddStr2 = "rn for more details, see:" + location. href;
If (LenStr> 50)
{NewContent = left (d, LeftNum) + AddStr + right (d, RightNum) + AddStr2 ;}
Else {NewContent = d ;}
ClipboardData. setData ("Text", NewContent );
}, 100)
} |