In cooking this up Friday, I experimented with the following and uncharacteristically failed to document it. I am sort of recreating it from memory here.
var range = document.createRange();
var selection = window.getSelection();
selection.removeAllRanges();
range.selectNodeContents(document.getElementById("touchMe"));
document.execCommand('copy');
selection.removeAllRanges();
Maybe try .selectNode instead of .selectNodeContents if .selectNodeContents does not work.
No comments:
Post a Comment