I want to copy the content of an asp:label using javascript.
I can do it using this method:
strContent = document.getElementById('MainContent_lblHtml').innerText;
window.clipboardData.setData("Text", strContent);
but it strips the formatting and just copies text. (I assume because the dataformat is set to “text”.)
The label contains some formatted html. I want to preserve the format, getting the same effect as if I were to highlight it on screen with my mouse, and then copy into (for example) a word document.
Updated
The following will highlight the desired div and then copy the HTML to the clipboard. Go to Word and press CTRL+V to paste the formatted html into a document.