Automatically add copyright information js Code to the copied content

Source: Internet
Author: User

Add a version or connection address after the content of the website copy. This is what most webmasters do now, now I have sorted out some frequently-used JavaScript codes for automatically adding copyright information to the copied content. Some may randomly add copyright codes in the middle of the article.

Method 1: Add version information to the end of the copy of common code.

When copying the website content, we can add a piece of code to indicate the source of the article to keep the information of the website author.

First, create a js file named copymsg. js,

The Code is as follows: Copy code

// Copy the content to automatically add copyright information
Var thehits = document. getElementById ("thehit ");
If (thehits! = Null ){
Thehits. innerHTML = "22936 ";
}

Document. body. oncopy = function ()
{
SetTimeout (
Function ()
{
Var text = clipboardData. getData ("text ");
If (text)
{
Text = text + "rn this article

Related Article

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.