2005-11-23复制内容到用户的剪贴板

TAG:代码分享 JScript

一段可以将内容复制到用户的剪贴板的代码:
1.将下面的代码复制到 <head> 内
---------------------------------------------------------------
<style>
.highlighttext{
background-color:yellow;
font-weight:bold;
}
</style>

<script language="Javascript">
<!--

//specify whether contents should be auto copied to clipboard (memory)
//Applies only to IE 4+
//0=no, 1=yes
var copytoclip=1

function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&&copytoclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout("window.status=''",1800)
}
}
//-->
</script>
--------------------------------------------------------------
2.将下面的代码复制到 <body>
--------------------------------------------------------------
<form name="test">
<a class="highlighttext" href="javascript:HighlightAll('test.select1')">Select All</a><br>
<textarea name="select1" rows=10 cols=35 >This is some text. This is some text. This is some text. This is some text.</textarea>
</form>






TrackBack URL: {#ping_url} 
Ghost 发表于 16:06  |  引用_0  |  编辑

Recent Articles

Recent Comments

Recommend

广 州
The WeatherPixie

Search Engine Optimization

CSS森林:30247792
(精神正常者慎入!)

有话就说
有话要说
011 本BLOG[原]部分的内容采用创作共用授权,请尊重劳动成果,谢谢。
Copyright © 2006 风的影子. All rights reserved.   FORESt.blOGbUS.COM  BLOGBUS.COM