How to Add Read More Source Link on Copied Content?


#1

Hi Team,

I saw many content websites having an option where we copy content from a page it also includes
**Read More: <Source Link................>** in Copied text

Please help me how to implement this option in my blogger template

I have searched this option and find for wordpress

Copy the following code into your theme’s functions.php file or a site-specific plugin: (for Wordpress)

function add_copyright_text() {
	if (is_single()) { ?>

<script type='text/javascript'>
function addLink() {
	if (
window.getSelection().containsNode(
document.getElementsByClassName('entry-content')[0], true)) {
    var body_element = document.getElementsByTagName('body')[0];
    var selection;
    selection = window.getSelection();
	var oldselection = selection
    var pagelink = "<br /><br /> Read more at WPBeginner: <?php the_title(); ?> <a href='<?php echo wp_get_shortlink(get_the_ID()); ?>'><?php echo wp_get_shortlink(get_the_ID()); ?></a>"; //Change this if you like
    var copy_text = selection + pagelink;
    var new_div = document.createElement('div');
	new_div.style.left='-99999px';
	new_div.style.position='absolute';

    body_element.appendChild(new_div );
    new_div.innerHTML = copy_text ;
    selection.selectAllChildren(new_div );
    window.setTimeout(function() {
        body_element.removeChild(new_div );
    },0);
}
}


document.oncopy = addLink;
</script>

<?php
}
}

add_action( 'wp_head', 'add_copyright_text');

But what incase of Blogger


#2

Do you mean this tool:

http://www.tynt.com/product_copypaste

Sign up first, then follow next instruction :innocent:, I don’t use this thing anymore since i …so i dont remember how to put the code on template.

Sorry :grimacing:


#3

Yes I was requested for the same. if we go through the link provided by you.

need to signup and use of there code is not much good, instead we may have our own code.

may be our admin help on this.


#4

@chinnilax

Try this .

<!-- Copyright Notice -->
<script type='text/javascript'>
function addLink() {
var body_element = document.getElementsByTagName(&#39;body&#39;)[0];
var selection;
selection = window.getSelection();
var pagelink = &quot;<br/><br/> Read more at: <a href='&quot;+document.location.href+&quot;'>&quot;+document.location.href+&quot;</a><br/>Copyright &#169; SpicyTechTips&quot;; // You can change this to your prefered text
var copytext = selection + pagelink;
var newdiv = document.createElement(&#39;div&#39;);
newdiv.style.position=&#39;absolute&#39;;
newdiv.style.left=&#39;-99999px&#39;;
body_element.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function() {
body_element.removeChild(newdiv);
},0);
}
document.oncopy = addLink;
</script>

Add the above code above

</head>

on blogger template.

Change SpicyTechTips from above code to your desire title.

So when someone try to copy and paste your content it will look like this.

I hope this is what you were asking for.


Can we use wordpress readmore scripts in blogger?
#5

Thanks @shahsantosh, I’ll check and update you any how thanks for the support.


#6

@chinnilax My pleasure. I feels good to share the knowledge i know. Try it. It will surely work. Coz i had also check it on my blog and it works nicely. As you see in the screenshot. Happy Blogging :smile: