MOYUN(/Java/SQL/Linux/DevOps/运维/架构/管理/敏捷/开发)

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
 1  <html>
 2         <head>
 3                 <style type="text/css">
 4                         #d_clip_button {
 5                                 text-align:center; 
 6                                 border:1px solid black; 
 7                                 background-color:#ccc; 
 8                                 margin:10px; padding:10px; 
 9                         }
10                         #d_clip_button.hover { background-color:#eee; }
11                         #d_clip_button.active { background-color:#aaa; }
12                 </style>
13         </head>
14         <body>
15                 <script type="text/javascript" src="zeroclipboard/ZeroClipboard.js"></script>
16                 
17                 Copy to Clipboard: <input type="text" id="clip_text" size="40" value="Copy me!"/><br/><br/> 
18         
19                 <div id="d_clip_button">Copy To Clipboard</div>
20         
21                 <script language="JavaScript">
22                         var clip = new ZeroClipboard.Client();
23                         
24                         clip.setText( '' ); // will be set later on mouseDown
25                         clip.setHandCursor( true );
26                         clip.setCSSEffects( true );
27                         
28                         clip.addEventListener( 'load', function(client) {
29                                 // alert( "movie is loaded" );
30                         } );
31                         
32                         clip.addEventListener( 'complete', function(client, text) {
33                                 alert("Copied text to clipboard: " + text );
34                         } );
35                         
36                         clip.addEventListener( 'mouseOver', function(client) {
37                                 // alert("mouse over"); 
38                         } );
39                         
40                         clip.addEventListener( 'mouseOut', function(client) { 
41                                 // alert("mouse out"); 
42                         } );
43                         
44                         clip.addEventListener( 'mouseDown', function(client) { 
45                                 // set text to copy here
46                                 clip.setText( document.getElementById('clip_text').value );
47                                 
48                                 // alert("mouse down"); 
49                         } );
50                         
51                         clip.addEventListener( 'mouseUp', function(client) { 
52                                 // alert("mouse up"); 
53                         } );
54                         
55                         clip.glue( 'd_clip_button' );
56                 </script>
57         </body>
58         </html>

//记得设置ZeroClipboard.swf路径

ZeroClipboard.js ----------------> moviePath: 'zeroclipboard/ZeroClipboard.swf', // URL to movie

 

posted on 2013-11-15 14:15  moyun-  阅读(151)  评论(0编辑  收藏  举报