













如何用javascript拷贝当前页中被选中的文字?
请教代码如何写,谢谢!
其他的代码只是辅助演示!
[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]
<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]
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。