top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Adding a link to the copied webtext?

+1 vote
346 views

Many websites wants to add “Read More” link or copyright notice to the bottom of text copied from their web pages which helps to improve the reach of the webpage.

JavaScript Solution

Following is the code in the JavaScript which you just need to add to the webpage and rest of the magic would be done by this?

<script type="text/javascript">

function addLink() {
    var body_element = document.getElementsByTagName('body')[0];
    var selection;
    var n;
    selection = window.getSelection();
    n = selection.toString().indexOf("<");
    if (n == -1) 
    {
        var pagelink = "<br /><br /> Read more at: <a href='"+document.location.href+"'>"+document.location.href+"</a>";
        var copytext = (selection + pagelink).replace(/ /g,"\u00a0").replace(/\n/g, "<br />");
        var newdiv = document.createElement('div');
        newdiv.style.position='absolute';
        newdiv.style.left='-99999px';
        body_element.appendChild(newdiv);
        newdiv.innerHTML = copytext;
        selection.selectAllChildren(newdiv);
        window.setTimeout(function() {
                body_element.removeChild(newdiv);
                },0);
    }
}
document.oncopy = addLink;
</script>

Above code is based on http://bavotasan.com/2010/add-a-copyright-notice-to-copied-text/ with modifications and currently running at QueryHome.

Alternate Service:

If you dont want to use the other alternative is to use tynt service which can be accessed at https://www.tynt.com/

posted May 29, 2014 by Salil Agrawal

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button


Related Articles

What is Bootstrap ?

Bootstrap is an open-source Javascript framework developed by the team at Twitter.
It is a combination of HTML, CSS, and Javascript code designed to help build user interface components.
Bootstrap was also programmed to support both HTML5 and CSS3.

Also it is called Front-end-framework.

Bootstrap is a free collection of tools for creating a websites and web applications.

It contains HTML and CSS-based design templates for typography, forms, buttons, navigation and other interface components, as well as optional JavaScript extensions.

Some Reasons for programmers preferred Bootstrap Framework

  • Easy to get started
  • Great grid system
  • Base styling for most HTML elements(Typography,Code,Tables,Forms,Buttons,Images,Icons)
  • Extensive list of components
  • Bundled Javascript plugins

Pre Styled Components

Some of the components pre styled are:

  1. Dropdowns
  2. Button Groups
  3. Navigation Bar
  4. Breadcrumbs
  5. Labels & Badges
  6. Alerts
  7. Progress Bar
  8. And many others.

Video Reference

https://www.youtube.com/watch?v=V7x_hosDoIo

READ MORE
...