TechKnowTalkies: Copy the Code Button in Blogger | 100% Free Script | June 2021 | Working

Search This Blog

Friday, June 11, 2021

Copy the Code Button in Blogger | 100% Free Script | June 2021 | Working

This article will show you how to easily embed the 'Copy' button in your Blogspot website. You might write some article or code snippet in your blog, and you want the reader to copy some of that using a simple copy button without much effort.

Advantages of this script :
  1. No coding skill required
  2. Compatible with all free(or premium) blogger themes available
  3. Pure HTML code, the script has no hidden tags or JAVA/JSON scripts
  4. Just copy and paste the code in your blog post
The interesting fact about this blog post is, this post itself used this same script. 

So let us directly jump into business!

Step 1: Log into your blogger.com control panel, create a new post and go to HTML view.
Step2: Copy this code given at the end of this post. Now there are two ways you can copy it.
a) You can drag your mouse over the code section, right click and copy the code(no need to modify anything)
b)  Click on the 'Copy the Code' button(for this case you need to slightly modify the code before pasting it in your blog post)

For Step2: (a)

  1. Copy below code , starting from <textarea to <br />
  2. Whatever code or text you want readers to copy-paste that in place of {----This code/text will be inside copy box----}

<textarea cols="100" id="htmlText" readonly="" rows="20" style="background-color: #1b1b1b; color: white; height: auto; overflow: auto; resize: none; width: 100%;">
{----This code/text will be inside copy box----}
</textarea>
<button id="htmlBtn" onclick="copyhtml()" style="background-color: #4caf50; border: none; color: white; cursor: pointer; display: inline-block; font-size: 16px; margin: 4px 2px; padding: 10px 30px; text-align: center; text-decoration: none;">Copy the Code</button>
<script>
function copyhtml() {
const text = document.querySelector("#htmlText");
const btnText = document.querySelector("#htmlBtn");
text.select();
document.execCommand("copy");
btnText.textContent = "Code Copied Successfully";
setTimeout(function(){
btnText.textContent = "Copy the Code";
}, 5000);
}
</script>
<br /><br />

For Step2: (b)

  1. Click on the 'Copy the Code' button
  2. Once the code is copied into the clipboard, paste that to any HTML editor, say, Notepad ++ or blogger HTML view itself.
  3. Now find first <//textarea and replace that with <textarea that means just remove those two // symbols.
  4. Find second <//textarea and replace that with </textarea that means remove one / symbol
  5. Find <//button and replace that with <button that means just remove those two // symbols.
  6. Now find first <//script and replace that with <script that means just remove those two // symbols.
  7. Find second <//script and replace that with </script that means remove one / symbol
  8. Finally find <br //><br //> and replace that with <br /><br /> that means remove one / symbol from each angular bracket< >


You should follow only one method, i.e. either Step2: (a) or Step2: (b). Do not follow both the steps. 

Please comment if you are still facing any issue using this script on your blogger.com website, we will help you resolve that.

No comments:

Post a Comment

Featured Post

Join in Any 18+ WhatsApp Groups(10000+) in A Single Click | 2021

Welcome to this blog. Here, we love to share with you all the internet-related tips and tricks. If you plan to join different kinds of...