我的博客 我的地盘
代码1:
<script>
function selecturl(){
z=document.body.createTextRange();
z.moveToElementText(selecturlDiv);
z.select();
}
</script>
<span onmousemove='selecturl()' id=selecturlDiv><script>document.write(location.href)</script>


代码2:
<script>
function copyCode(o){o.select();var js=o.createTextRange();js.execCommand("Copy");alert("复制成功!");}
document.write("<table align=center class=tableborder1 cellpadding=1 cellspacing=0><tr>");
document.write("<td width=10% nowrap class=tablebody1>本页URL地址(双击复制):</td>");
document.write("<td class=tablebody1><textarea onfocus=this.select() style='width:100%;overflow-y:visible;' ondblclick=copyCode(this) rows=1>");
document.write(self.location+"</textarea></td></tr></table>");
</script>


代码3:
<script language="javascript">
<!--
function copyToClipBoard(){
   var clipBoardContent=document.location;
   clipBoardContent+='\r\n';
   window.clipboardData.setData("Text",clipBoardContent);
   alert("耶!复制成功喽!你可以粘贴在QQ消息里送给你的好朋友呀!再次感谢你对 {TheBlogTitle} 的支持哦!");
}
//-->
</script>
<script language='javascript'>
   document.write("<img src=\"templates/{TemplateName}/images/db.gif\" width=\"49\" height=\"17\">");
   document.write("<input size=\"60\" value=\""+document.location+"\"><input type=\"button\" value=\"推荐给朋友\" title=\"点击复制地址到剪贴板,直接在MSN/QQ上粘贴即可.\" onclick=\"copyToClipBoard()\">");
</script>


代码4:用flash+javascript实现了在不同浏览器里复制的功能 测试了一下 好像不能获取页面地址
1.先下载这个FLASH文件:右键下载 文件改名为_clipboard.swf
2.复制代码
<html>
<head>

<title>用flash+javscript实现网页上的文本复制</title>

</head>
<body>
<script type="text/javascript" language="javascript">
function copyit(textit) {
if (window.clipboardData) {
window.clipboardData.setData("Text",textit);
} else {

var flashcopier = 'flashcopier';
if(!document.getElementById(flashcopier)) {
var divholder = document.createElement('div');
divholder.id = flashcopier;
document.body.appendChild(divholder);
}
document.getElementById(flashcopier).innerHTML = '';
var divinfo = '<embed src="_clipboard.swf" FlashVars="clipboard='+textit+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
document.getElementById(flashcopier).innerHTML = divinfo;
}
}
//copyit("")

</script>
<input type="text" value="用flash+javscript实现网页上的文本复制" id="g">
<a href="javascript:copyit(document.getElementById('g').value);">复制一下</a>
</body>
</html>


收藏本日志请用永久地址:http://www.5dzone.net/read.php?158
版权所有。转载时必须以链接形式注明 作者和原始出处及本声明!
如果你有其他要求,可用这个邮箱联系我:
0 Comment(s)
发表评论
  昵称 [注册]
  密码 (游客无需密码)