Created
July 25, 2020 00:28
-
-
Save hallison/9dc0ecdec3190de9a115405f85ba654c to your computer and use it in GitHub Desktop.
Copy and paste with footer information (from https://braziljournal.com/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$(document).on('copy', function () { | |
var selection = window.getSelection(); | |
var copyFooter = '<br><br>Leia mais em <a href="' + document.location.href + '">' + document.location.href + '</a>'; | |
var copyHolder = $('<div>', { | |
html: (selection + '').substring(0, 140) + '...' + copyFooter, | |
style: { | |
position: 'absolute', | |
left: '-99999px'} | |
} | |
); | |
$('body').append(copyHolder); | |
selection.selectAllChildren(copyHolder[0]); | |
window.setTimeout(function() { | |
copyHolder.remove(); | |
}, 0); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment