Flash 10 之后 _clipboard.swf 失效了,因为flash10中规定了只有在swf上进行了实际的操作(比如鼠标点击)才能启动剪切板。
Zero Clipboard ,它包含一个flash影片和一个JavaScript接口,这个flash是透明的(不是隐藏),用户不会察觉到它的存在。这个flash覆盖在一个DOM元素上,比如button,div之类,当点击这个DOM时,你实际点击的是这个flash,这个作用在flash上的动作能够开启flash的剪切板。这实际上就是一种clickjacking。
<
script type
=
"
text/javascript
"
src
=
"
ZeroClipboard.js
"
></
script
>
< script language = " JavaScript " >
var clip = null ;
function $(id) { return document.getElementById(id); }
function init() {
clip = new ZeroClipboard.Client(); // 新建
clip.setHandCursor( true ); // 设定MOUSE样式
clip.addEventListener( ' load ' , my_load); // 载入时
clip.addEventListener( ' mouseOver ' , my_mouse_over); // 点击时
clip.addEventListener( ' complete ' , my_complete); // 点击后
clip.glue( ' d_clip_button ' ); // 绑定按所扭ID
}
function my_load(client) {
alert( " Flash movie loaded and ready. " );
}
function my_mouse_over(client) {
// we can cheat a little here -- update the text on mouse over
clip.setText( $( ' fe_text ' ).value );
}
function my_complete(client, text) {
alert( " Copied text to clipboard: " + text );
}
</ script >
< script language = " JavaScript " >
var clip = null ;
function $(id) { return document.getElementById(id); }
function init() {
clip = new ZeroClipboard.Client(); // 新建
clip.setHandCursor( true ); // 设定MOUSE样式
clip.addEventListener( ' load ' , my_load); // 载入时
clip.addEventListener( ' mouseOver ' , my_mouse_over); // 点击时
clip.addEventListener( ' complete ' , my_complete); // 点击后
clip.glue( ' d_clip_button ' ); // 绑定按所扭ID
}
function my_load(client) {
alert( " Flash movie loaded and ready. " );
}
function my_mouse_over(client) {
// we can cheat a little here -- update the text on mouse over
clip.setText( $( ' fe_text ' ).value );
}
function my_complete(client, text) {
alert( " Copied text to clipboard: " + text );
}
</ script >