Firefox Copying To Clipboard Protection

Hello I was trying to get copying and pasting working in Firefox 2 but couldn’t get it to work, I get the error

Clipboard is not defined dhtmlXGrid_nxml.js (line 196)

I tried the usual tricks to enable clipboard, including setting, in about:config

signed.applets.codebase_principal_support = true

And the following in user.js:

user_pref(“capability.policy.policynames”, “allowclipboard”);

user_pref(“capability.policy.allowclipboard.sites”, “”);

user_pref(“capability.policy.allowclipboard.Clipboard.cutcopy”, “allAccess”);

user_pref(“capability.policy.allowclipboard.Clipboard.paste”, “allAccess”);

But the error still occurs.

I have been looking around this area and I found an alternative solution that works well in Firefox, there are some details here: … _Clipboard

I modified the copy and paste methods in dhtmlXGrid_nxml.js as follows and now copying/pasting works in Firefox and better still it pops up a security dialogue asking whether or not you want to allow the site access to the clipboard, so no need to fiddle with all the config options.



    if (window.clipboardData) {




    else {“UniversalXPConnect”)


        var copytext = val;


        var str = Components.classes[";1"].


        if (!str) return false;

         = copytext;


        var trans = Components.classes[";1"].


        if (!trans) return false;



        trans.setTransferData(“text/unicode”, str, copytext.length * 2);


        var clipid = Components.interfaces.nsIClipboard;

        var clip = Components.classes[";1"].getService(clipid);

        if (!clip) return false;


        clip.setData(trans, null, clipid.kGlobalClipboard);






    if (window.clipboardData) {

        return window.clipboardData.getData(“Text”)




        var clip = Components.classes[";1"].getService(Components.interfaces.nsIClipboard);

        if (!clip) return false;


        var trans = Components.classes[";1"].createInstance(Components.interfaces.nsITransferable);

        if (!trans) return false;



        clip.getData(trans, clip.kGlobalClipboard);


        var str = new Object();

        var strLength = new Object();


        trans.getTransferData(“text/unicode”, str, strLength);



        if (str) str = str.value.QueryInterface(Components.interfaces.nsISupportsString);

        if (str) pastetext =, strLength.value / 2);


        return pastetext;



Thanks for your code propositions, I incorporated this logic in main code branch.
Updated file for dhtmlxGrid 1.3 attached. (4.19 KB)