首页
微信
安卓
接口
移动
前端
专题
文档库
工具
网址
§
ITPOW
>>
文档
>>
JavaScript
>>
DOM & DHTML
复制内容到用户的剪贴板
作者: 来源: 日期:2004-10-8
<style> .highlighttext{ background-color:yellow; font-weight:bold; } </style> <script language="Javascript"> <!-- /* Highlight and Copy form element script- By Dynamicdrive.com For full source, Terms of service, and 100s DTHML scripts Visit http://www.dynamicdrive.com */ //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&©toclip==1){ therange=tempval.createTextRange() therange.execCommand("Copy") window.status="Contents highlighted and copied to clipboard!" setTimeout("window.status=''",1800) } } //--> </script> <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>
[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
相关文章
创建于2005年
渝ICP备05010272号-1
电邮:
cftea@126.com
即将跳转...