<style type=
"text/css"
>
body { font-family:arial,sans-serif; font-size:9pt; }
.copyit {text-align:center; border:1px solid #FD6001; background-color:#ED730B; margin:10px; padding:2px 5px; cursor:pointer; font-size:12px; border-radius:3px;}
.copyit.hover { background-color:#FD6001;}.copyit.active { background-color:#d25102;}
.copy_info{width:260px;height:100px;border:1px solid #ccc;padding:5px;}
</style>
<script type=
"text/javascript"
src=
"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
></script>
<script type=
"text/javascript"
src=
"/js/ZeroClipboard/ZeroClipboard.js"
></script>
<div
class
=
"clip_container"
>
<textarea id=
"fe_text"
cols=50 rows=5
class
=
"copycnt"
>第1个被复制的内容!!!</textarea>
<b
class
=
"copyit"
>复制内容</b>
</div>
<br/>
<div
class
=
"clip_container"
>
<textarea id=
"fe_text"
cols=50 rows=5
class
=
"copycnt"
>第2个被复制的内容!!!</textarea>
<b
class
=
"copyit"
>复制内容</b>
</div>
<script type=
"text/javascript"
>
var
clip = null;
function
copyThis() {
if
($.browser.version==6.0){
$(
'.copyit'
).bind(
"click"
,
function
(){
var
code=$(this).parents(
".clip_container"
).find(
".copycnt"
).text();
window.clipboardData.setData(
"Text"
,code);
alert(
'被复制的内容:\n'
+code);
})
return
;
}
ZeroClipboard.setMoviePath(
"http://img.jb51.net/js/scripts/clipboard.swf'"
);//如果ZeroClipboard.js, ZeroClipboard.swf放在同一目录下,可省略这句;
clip =
new
ZeroClipboard.Client();
$(
'.copyit'
).mouseover(
function
() {
var
code=$(this).parents(
".clip_container"
).find(
".copycnt"
).text();
clip.setText(code);
if
(clip.div) {
clip.reposition(this);
}
else
{
clip.glue(this)};
} );
clip.addEventListener(
'complete'
,
function
(client, text){
alert(
"被复制内容:\n"
+text);
});
}
copyThis();
</script>
<textarea style=
"width:300px;height:300px;"
>
粘贴复制的内容到这里试试!!
</textarea>