2014-03-02 93 views
0

我想知道爲什麼它做的一切,在ZeroClipboard - 複製到剪貼板的問題。

只是沒有實際的文本拷貝該行:client.on( 'dataRequested',函數(客戶端,參數){

$("body").on("click","#bonus-copy",function(){ 

    var _globalConfig = { 

     swfPath: "js/ZeroClipboard.swf", 
     trustedDomains: [window.location.host], 
     cacheBust: true, 
     forceHandCursor: false, 
     zIndex: 999999999, 
     debug: false, 
     title: null, 
     autoActivate: true, 
     hoverClass: "zeroclipboard-is-hover", 
     activeClass: "zeroclipboard-is-active", 
     trustedOrigins: null, 
     allowScriptAccess: null, 
     useNoCache: true, 
     moviePath: "ZeroClipboard.swf" 
    }; 

    var client = new ZeroClipboard(); 


    client.on('dataRequested', function(client, args) { 
     var text = document.getElementById('copy-text').value; 
     var windowsText = text.replace(/\n/g, '\r\n'); 
     client.setText(windowsText); 
     alert(windowsText); 
    }); 


}); 
+0

爲什麼要在每次點擊時設置全局變量 – Charlie

回答

0

您需要在點擊按鈕之前啓動並配置ZeroClipboard。