sample
sample

Reputation: 61

How to add Copy to clipboard functionality in ExtJs?

How to add Copy to clipboard functionality in ExtJs? It's working fine with IE browser but not Firefox, What else has to be altered to make it work in FF browser.

Code:

function selectCopy(txt,txtId)
{
    Ext.getCmp(txtId).focus();

    Ext.getCmp(txtId).selectText();

    var s = document.getElementById(txtId).value;

    var div = document.createElement('div');
    div.innerText = '"' + s + '"';
    document.body.appendChild(div);

    if (window.clipboardData  && clipboardData.setData){
        window.clipboardData.setData('text', s);}
    else
        return (s);
}

Upvotes: 2

Views: 7496

Answers (1)

ithcy
ithcy

Reputation: 5589

Answer: Firefox has to be altered. It cannot be done with JavaScript alone.

Clipboard access in the browser is considered a security risk. See this page for an explanation.

That said, you can achieve this with a combination of Flash and JavaScript. Zero Clipboard is one way.

Upvotes: 4

Related Questions