is there a way to copy something to the “clipboard” using javascript?
for example, the user clicks on an icon next to an address displayed on the screen and that address is automatically copied to their clipboard. then they can paste it into another document or application.
@Warren86Dec 01.2004 — #The example below does not use an icon, it uses a text link. The links in this case are names of people. When a user clicks a name, the hidden info associated with that name is copied to the clipboard. Currently, the hidden info happens to be a street address, but can be any text.
<HTML>
<Head>
<Script Language=JavaScript>
var isSecond = false; var isFirst = true;
function copyToClipboard(ID){
isRange = document.body.createControlRange(); isRange.add(document.all(ID)) if (isSecond) {if (confirm('This will erase the Clipboard. nnDo you want to CONTINUE?')){isRange.execCommand("Copy");alert('The Clipboard was overwritten with your selection.')}} else if (isFirst){isRange.execCommand("Copy");isFirst = false; alert('Your selection was copied to the Clipboard.')} isSecond = true; }
</Script>
<Body>
<center>
<H3>Copy Selected and Hidden Data to Clipboard</H3>
<Table id='data1' Style='display:none'><TD>John Doe, 456 Any Street, Columbus, OH 44444</TD></Table>