Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addLink() {
- var selection = window.getSelection();
- pagelink = ". Read more at: " + document.location.href;
- copytext = selection + pagelink;
- newdiv = document.createElement('div');
- newdiv.style.position = 'absolute';
- newdiv.style.left = '-99999px';
- document.body.appendChild(newdiv);
- newdiv.innerHTML = copytext;
- selection.selectAllChildren(newdiv);
- window.setTimeout(function () {
- document.body.removeChild(newdiv);
- }, 100);
- }
- document.addEventListener('copy', addLink);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement