/    Sign up×
Community /Pin to ProfileBookmark

automatically copy

I would like to be able to have people click on a link and the effect would be that a certain amount of hidden text would be automatically copied. So they click on a name and, for example, the name and address would automatically be copied so they can paste it into another document. Is this possible?
Thanks for any help.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Warren86Nov 01.2004 — <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>

<a href=javascript:copyToClipboard('data1') id='name1'>John Doe</a><br>

<Table id='data2' Style='display:none'><TD>Mary Roe, 123 Main Street, Avalon, PA 22222</TD></Table>

<a href=javascript:copyToClipboard('data2') id='name2'>Mary Roe</a><br>

<Table id='data3' Style='display:none'><TD>Henry Crow, 987 Easy Street, Paradise, CA 55555</TD></Table>

<a href=javascript:copyToClipboard('data3') id='name3'>Henry Crow</a>

</center>

</Body>

</HTML>
Copy linkTweet thisAlerts:
@WebskaterauthorNov 01.2004 — Thanks very much. I was hoping for an idea how to do it - but the whole code! Brilliant! Thanks again.
Copy linkTweet thisAlerts:
@Warren86Nov 01.2004 — You're welcome. Thank you for your kind consideration.
×

Success!

Help @Webskater spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...