Copy the webpage content, paste it, and add the implementation method of the URL automatically (specially organized by the script ).

Source: Internet
Author: User

Copy the webpage content, paste it, and add the implementation method of the URL automatically (specially organized by the script ).

I did not expect a function that I did not expect. Now it has been so fierce. I think that after we released it, I found many websites added this function the next day, and I regret it, otherwise, we will have more external links. Of course, there is also a dislike. If the tool is good, it depends on the person who uses it.

Today, I found that many of my friends liked this feature. Here, the Mini editor of the customer's House continues to provide a special version for everyone. You can choose to use it as needed.

When we open some websites and browse some articles, we feel very good. Therefore, we often copy the articles on these websites;

After that, paste it into the Word or notepad, save it, and "take it for yourself" while implementing "take it "!
If you are a webmaster like a beebot and work hard every day, when the content of your website is possessed by others without specifying the source address of the article, I think you will get angry!
Therefore, many webmasters do this to avoid this situation!
Add this function to the webpage. When someone else copies the website content and paste it into software such as Word or notepad, the detailed address of the website address or article source will be automatically added!
If you have encountered such a situation, please learn with me and how to achieve this effect!

Implementation Method:

The method is very simple. Just use the following code!

Copy codeThe Code is as follows:
<Script type = "text/javascript">
Document. body. oncopy = function (){
SetTimeout (function (){
Var text = clipboardData. getData ("text ");
If (text ){
Text = text + "\ r \ n article from: site name (http://www.bkjia.com) For details, see:" + location. href; clipboardData. setData ("text", text );
}
}, 100)
}
</Script>

Copy the above Code and paste it on the corresponding page of your website!

Note: This code is generally placed in the <body> area, or you can choose to put it somewhere!

Knowledge extension:

Although the above Code can avoid automatically adding URLs after copying, It is not flexible. If you want to modify or make any changes in the future, you must modify the code, we can use the JS file method introduced on the page to implement flexible functions!

Open notepad and copy and paste the following content in it (this code is similar to the above Code, but not the same, please note ):

Copy codeThe Code is as follows:
Document. body. oncopy = function (){
SetTimeout (function (){
Var text = clipboardData. getData ("text ");
If (text ){
Text = text + "\ r \ n article from: (http://www.bkjia.com) Article address:" + location. href; clipboardData. setData ("text", text );
}
}, 100)
}

Save the file as XX. js and store it in the corresponding directory of the website!

Finally, introduce the preceding XX. js file to the page, as shown in the following code:

<Script src = "DataFiles/Java/AddMyUrl. js" type = "text/jscript"> </script>

The above red code is the reference sample code!

Note: The introduced code is generally placed behind the content of the article, before </body>!

The above Code uses js to obtain the content of the clipboard. The following code uses js to obtain the selected content. The functions are the same. However, this is not enough.

<Html> <pead> <title> copy the content of the article to automatically add your website information </title> </pead> <body> This text is purely a test. You can copy it, paste it to other places and check whether the website is added to the website. </Body> </ptml> </P> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

The following section provides a copy of the content for you to add domain names in the middle, which is more difficult to find.

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.jb51.net)"; var AddStr2 = "from:"+location.href;if(LenStr > 50 ){NewContent = left(d,LeftNum)+AddStr+ right(d,RightNum)+AddStr2;}else{NewContent = d;}clipboardData.setData("Text",NewContent);}, 100 )}

Copy the content of the web page, paste it, and add the introduction of the web site to it. Later, we will find it better for you.


I copied the content of a webpage. When I pasted it, I found that the copied content was automatically added to its url. How can I achieve this in code?

Actually not implemented by code
In those places, the color of those words is set to the same color as the background color, which is invisible on the surface. For example, the background that Baidu knows is white.
Write such a paragraph
11111111111111111
<Font color = white> zhidao.baidu.com </font>
22222222222222222
On the surface, you only see 11111 and 222222. The URL in the middle is invisible because it is also white.
However, if you copy all the data, you can paste the web site.

After you copy a website article and paste it elsewhere, the code of the original link is automatically displayed. How can this problem be solved?

I will teach you a simple method!

You can copy the website file to the txt file first, that is, you can create a notepad file first and then enter the text of the website. The format is gone!
Then, copy it to word !!!!

Then you can directly copy it to frontpage or Dreamweaver!

The answer from the upstairs is really shameless !!!!!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.