ZeroClipboard - 复制到剪贴板问题。

时间:2014-03-02 11:25:28

标签: javascript jquery zeroclipboard

我想知道为什么它会做所有事情,而不是

上的实际文本副本
  

该行:client.on('dataRequested',function(client,args){

$("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);
    });


});

1 个答案:

答案 0 :(得分:0)

在点击按钮之前,您需要启动并配置ZeroClipboard。