惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
Engineering at Meta
Engineering at Meta
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
博客园_首页
雷峰网
雷峰网
V
Visual Studio Blog
爱范儿
爱范儿
A
About on SuperTechFans
量子位
N
Netflix TechBlog - Medium
Microsoft Security Blog
Microsoft Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
S
SegmentFault 最新的问题
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - voiow

C#资源汇总 弹出窗口在屏幕中央 Server.CreateObject 的调用失败 - voiow - 博客园 SQL Server 2005表分区的具体实现方法 Server 2005之Integration Service简单实例 获取SQL Server数据库里表容量大小 自定义用户控件属性 - voiow - 博客园 使用asp下的adodb.stream 下载文件而不是打开 javascript以list方式封装xml - voiow - 博客园 Dynamic XML from SQL Server - voiow 将数据库存储的附件写到文件夹上面 - voiow - 博客园 BizTalk使用发送端口组引起的问题解决方法 SQL Server日志清空方法 SQL SERVER 触发器实例 如何设计一个安全的WEBSERVICE 使用BizTalk Server常见问题处理 ASP.NET程序中常用的三十三种代码 浅谈反射与特性在接口系统中的应用(编码表转化) 使用window.createPopup();做的简单下拉菜单
如何用javascript拷贝当前页中被选中的文字? - voiow - 博客园
voiow · 2009-09-08 · via 博客园 - voiow

如何用javascript拷贝当前页中被选中的文字?
请教代码如何写,谢谢!

document.execCommand("copy")

其他的代码只是辅助演示!

[html]
<script defer>
var oMessage=document.all("phx")
var oTextRange=document.body.createTextRange();
with(oTextRange){
moveToElementText(oMessage);
execCommand("selectall")}
</script>
<div id=phx>bluediea</div>
<button onclick=document.execCommand("copy")>copy</button>
<textarea cols=12 rows=6/>[/html]


好用:)
Thank u!


帮忙处理一下select,paste.
[html]
<textarea cols=24 rows=6>study by blueidea HOT.</textarea>
<button onclick=document.execCommand("selectall")>select</button>
<button onclick=document.execCommand("copy")>copy</button>
<button onclick=document.execCommand("paste")>paste</button>
<button onclick=document.execCommand("cut")>cut</button>
[/html]


获取焦点就好了!

[html]
<textarea id=ta cols=24 rows=6>study by blueidea HOT.</textarea>
<button onclick=ta.focus();document.execCommand("selectall")>select</button>
<button onclick=document.execCommand("copy")>copy</button>
<button onclick=ta.focus();document.execCommand("paste")>paste</button>
<button onclick=document.execCommand("cut")>cut</button>
[/html]


8错8错
全了
[html]
<object  id=hh1  classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">  
<param  name="Command"  value="Minimize"></object>  
<object  id=hh2  classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">  
<param  name="Command"  value="Maximize"></object>  
<OBJECT  id=hh3  classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">  
<PARAM  NAME="Command"  value="Close"></OBJECT>  

<input  type=button  value=最小化  onclick=hh1.Click()>  
<input  type=button  value=最大化  onclick=hh2.Click()>  
<input  type=button  value=关闭1  onclick=hh3.Click()>  
<input  type=button  value=关闭2  onClick=javascript:window.close();return  false;>  
<a  href="javascript:close();">关闭本窗口</a>
<a  href=javascript:window.opener=null;window.close()>Close</a>
<hr>
<textarea id=ta cols=24 rows=6>study by blueidea HOT.</textarea>
<button onclick=ta.focus();document.execCommand("selectall")>select</button>
<button onclick=document.execCommand("copy")>copy</button>
<button onclick=document.execCommand("cut")>cut</button>
<button onclick=ta.focus();document.execCommand("paste")>paste</button>
<button onclick=document.execCommand("open")>open</button>
<button onclick=document.execCommand("saveas")>saveas</button>
<hr>
<input  type=button  value=刷新  name=refresh  onclick="window.location.reload()">

<input  type="button"  name="Button"  value="导入收藏夹"  onClick=window.external.ImportExportFavorites(true,'');>  

<input  type="button"  name="Button3"  value="导出收藏夹"  onClick=window.external.ImportExportFavorites(false,'');>  

<INPUT  name=Button2  onclick="window.external.AddFavorite(location.href,  document.title)"  type=button  value=加入收藏夹>  

<INPUT  name=Submit2  onclick="window.external.ShowBrowserUI('OrganizeFavorites',  null)"  type=button  value=整理收藏夹>  

<INPUT  name=Button  onclick='window.location  =  "view-source:"  +  window.location.href'    type=button  value=查看源文件>  

<INPUT  name=Button  onclick="window.external.ShowBrowserUI('LanguageDialog',  null)"  type=button  value=语言设置>  

<INPUT  name=Submit  onclick=history.go(1)  type=submit  value=前进>  

<INPUT  name=Submit2  onclick=history.go(-1)  type=submit  value=后退>
[/html]