Snap Builder Public Codes Library
Snap | Generators | Login | Browse | Search | Enter Code | Export Snap Builder Public Codes Library

 

Category: Javascript Codes Library >> Copyright >> Add Author Credit Link


Code Snippet </> Info


Snippet Name: Add Author Credit Link

Description: Automagically add an author credit link to any copied text from your web page.

Compatible Browsers:
Chrome BrowserFirefox BrowserOpera BrowserSafari Browser


Example: View Code Demo

Note: Change the copyright notice to your needs.

Author: Snap Builder <snippets@snapbuilder.com>

Last Modified: 2019-12-09 02:29:17

Language: javascript

Highlight Mode: javascript

Copy Codes: Use Free Notepad ++
Bookmark and Share

Snap HTML Code Editor:
Paste the source code, make changes and instantly see it in live preview.
Snap HTML Code Editor


  About Copying
Copied To Clipboard!

<html> <head> <title>Add Author Credit Link</title> <script type="text/javascript"> /* Begin Add Author Credit Link == This Script Free To Use Providing This Notice Remains == == This Script Has Been Found In The https://snapbuilder.com Free Public Codes Library == == NOTICE: Though This Material May Have Been In A Public Depository, Certain Author Copyright Restrictions May Apply == */ function addLink() { var body_element = document.getElementsByTagName('body')[0]; var selection; selection = window.getSelection(); var pagelink = "<br /><br /> Read more at: <a href='"+document.location.href+"'>"+document.location.href+"</a><br />Copyright SnapBuilder.com"; // change this to your needs var copytext = selection + pagelink; 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> </head> <body> <p>Just add this code snippet between your document HEAD tags, and change the copyright notice to your needs.</p> <p>To test it out, copy something from the paragraph below and paste it into your favorite text editor.</p> <div style="padding:10px;width:90%;font-family:verdana;font-size:13px;line-height:17px;border:1px solid #007730;background:#eee;"> This is some random text to show you how the "Add Author Credit Link" JavaScript code snippet works on a web page. </div> </body> </html>


[ Snippet Options ]

 

© 2002 -  Snap Builder Public Codes Library