javascript---click copy the content to the clipboard
Posted
by
runeveryday
on Stack Overflow
See other posts from Stack Overflow
or by runeveryday
Published on 2010-12-31T02:29:08Z
Indexed on
2010/12/31
2:54 UTC
Read the original article
Hit count: 203
JavaScript
the following is the code. but it doesn't work. what's wrong with it? thank you.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>no title</title>
<script type="text/javascript">
function copyToClipBoard(content){
var clipBoardContent = '';
clipBoardContent = content;
window.clipboardData.setData("Text",clipBoardContent);
alert('have copied to the clipboard');
}
<body>
<textarea rows="4" cols="60" id="url">www.example.com</textarea>
<input type="button" value="click me" onclick="copyToClibBoard (document.getElementById ('url').value);" />
</body>
© Stack Overflow or respective owner