JS+flash实现chrome和ie浏览器下同时可以复制粘贴
更新时间:2013年09月22日 15:37:52 作者:
chrome和ie同时可以复制粘贴,想必大家一直思索的问题在本文将有一个不错的实现,下面为大家介绍下JS+flash是如何实现的,感兴趣的朋友可以参考下
利用2个文件
ZeroClipboard.js
ZeroClipboard.swf
<script type="text/javascript" src="ZeroClipboard.js"></script>
<script language="JavaScript">
var clip = null;
function $(id) { return document.getElementById(id); }
function init(xm) {
clip = new ZeroClipboard.Client();
clip.setHandCursor( true );
clip.addEventListener('load', function (client) {
debugstr("Flash movie loaded and ready.");
});
clip.addEventListener('mouseOver', function (client) {
// update the text on mouse over
clip.setText($('txt_links').value );
});
clip.addEventListener('complete', function (client, text) {
debugstr(xm );
});
clip.glue( 'd_clip_button', 'd_clip_container' );
}
function debugstr(msg) {
if(msg=='1'){
alert('复制成功,请用Chrl+V粘贴');
//alert('chushihu,请用Chrl+V粘贴');
}else{
}
}
</script>
注意:<body onload="init(1);">
ZeroClipboard.js
ZeroClipboard.swf
复制代码 代码如下:
<script type="text/javascript" src="ZeroClipboard.js"></script>
<script language="JavaScript">
var clip = null;
function $(id) { return document.getElementById(id); }
function init(xm) {
clip = new ZeroClipboard.Client();
clip.setHandCursor( true );
clip.addEventListener('load', function (client) {
debugstr("Flash movie loaded and ready.");
});
clip.addEventListener('mouseOver', function (client) {
// update the text on mouse over
clip.setText($('txt_links').value );
});
clip.addEventListener('complete', function (client, text) {
debugstr(xm );
});
clip.glue( 'd_clip_button', 'd_clip_container' );
}
function debugstr(msg) {
if(msg=='1'){
alert('复制成功,请用Chrl+V粘贴');
//alert('chushihu,请用Chrl+V粘贴');
}else{
}
}
</script>
注意:<body onload="init(1);">
相关文章
JavaScript中定时控制Throttle、Debounce和Immediate详解
大家可能都知道JavaScript遵循事件驱动的编程范例,这意味着一些行为可以激活一些响应,并且这些响应仅在发生特定的行为时才被激活。这篇文章将给大家详细介绍JavaScript中的定时控制Throttle、Debounce和Immediate,有需要的朋友们可以参考借鉴,下面来一起看看吧。2016-11-11
javascript一个无懈可击的实例化XMLHttpRequest的方法
由于IE新旧版本以及与其他浏览器在ajax技术上的不同,往往需要对不同的浏览器做不同的处理,除了笨拙的浏览器嗅探技术,大约也就是对象检测技术可用了。2010-10-10


最新评论