To add extra info in bottom of copied text - I want to use the following JS:
<script>
document.addEventListener('copy', (event) => {
const pagelink = `\n\nRead more at: ${document.location.href}`;
event.clipboardData.setData('text', document.getSelection() + pagelink);
event.preventDefault();
});
</script>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br/>
<textarea name="textarea" rows="7" cols="50" placeholder="paste your copied text here"></textarea>
Since it's the most recent version. But the problem is, it does NOT preserve the HTML tags and attributes like a, style, textarea etc. unlike default copy/paste (verified the results in MS-Word). It's not even hyperlink the url.
Is there anyway I can preserve the HTML stuff (like default or better) and also add reference in copied text?
Or is any better small piece of code that works cross-browser?