当前位置:首页 >> 

用flash+javascript实现网页中复制数据功能

来源: 网络资源 字体:[ ] 我要投稿

  

经常在网页上看见“复制本页网址,给你的朋友分享”之类的话,点按钮,在IE下能复制成功,而在firefox和opera等其他浏览器就不行
下面的例子使用flash(as)+javascript实现了在不同浏览器里复制的功能,这样做的好处就是规避了浏览器兼容的问题。也就是说支持firefox,IE,OPERA

下载FLASH文件:下载,右键另存

代码如下:

以下为引用的内容:

<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>

上一页:没有了
下一 页:HTML中使用空格排版的问题
关于我们 - 网 站地图 - 友情连接 - 登陆投稿 - 版权声明 - 广告服务 - 联系我们 - 留言本
Copyright © 2008-2009 Www.999net.Com All Rights Reserved
E-mail:WebMaster@999net.com
Powered BY 中国站长网 - 草根站长资讯信息中心,打造中国最优秀站长网