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 html5 canvas畫布中刪除一個塊區(qū)域的方法
這篇文章主要介紹了JavaScript html5 canvas畫布中刪除一個塊區(qū)域的方法,涉及JavaScript結合html5操作canvas畫布圖形繪制的技巧,需要的朋友可以參考下2016-01-01js 剪切板的用法(clipboardData.setData)與js match函數介紹
這篇文章主要是對js中剪切板的使用方法(clipboardData.setData)與js中的match函數進行了介紹。需要的朋友可以過來參考下,希望對大家有所幫助2013-11-11