Zapp: document.execCommand('Copy')

Beitrag lesen

Hallo willie,

wenn ich alles richtig verstanden hab, ist das wirklich nur zum kopieren von _selektiertem_ text gedacht: "Copies the current selection to the clipboard." schade!

Du kannst das mit einer Textrange machen:

sel=document.body.createTextRange();
sel.moveToElementText(document.getElementById('myDiv'));
sel.execCommand('Copy');

<div id=myDiv>...der zu kopierende Text...</div>

Grüße, Stefan