Version 25 no longer allows copy to clipboard
This is a follow-up to https://support.mozilla.org/en-US/questions/936323 since that question says "This thread was archived. Please ask a new question if you need help".
In older versions of Firefox, I could set `signed.applets.codebase_principal_support` in `about:config`, so that web sites trying to write to my clip board would get a pop-up asking me whether I want to allow this.
In newer version of Firefox (currently 25), this functionality does not work any more.
I am developing/maintaining a password tool that allows you to copy a password into the clipboard *without viewing it* (so that it cannot be read off the screen by bystanders). This used to work in oder Firefox versions, but now it stopped working.
I have read the related links, but they are quite out of date:
http://kb.mozillazine.org/Granting_JavaScript_access_to_the_clipboard (not edited since 2010, others reported that it doesn't work) http://www-archive.mozilla.org/projects/security/components/signed-scripts.html (linked from the page above, mentions itself that it is out of date) https://addons.mozilla.org/en-US/firefox/addon/allowclipboard-helper/ (does not seem to work)
Is there any way in current Firefox to write to the clipboard?
Thank you!
All Replies (6)
You're doing this in an extension? Extensions typically have privileges that ordinary websites do not have. For advice on those mechanisms, you could try one of these forums:
The code that I posted in the that thread ([/questions/936323#answer-393468]) still works for me.
What method are you using to copy data to the clipboard?
Is that code that you run on a web page?
If that is the case then it most likely won't work and you will have to code this in an extension.
No, I was not doing this in an extension, I was using plain Javascript.
I was using this: https://gist.github.com/nh2/7406314
Is there a non-extension way to do this?
Firefox has a password file in it. You could also go to the Firefox add-on web page for password add-ons to help you. There as also automatic form fillers you can look at. [https://addons.mozilla.org/en-US/firefox/ Firefox add-ons web site Firefox add-ons.]
The netscape.security.PrivilegeManager.* prefs are no longer supported in current Firefox releases (Bug 546848), so you can't use this anymore.
For now, I help myself with something like this:
function copyToClipboard(text) {
// Spawn an invisible text box (far outside the document),
// put the text in and select it so that the user can copy
// it with the platform specific key combination.
$('<input type="text" class="hidden-copy-input">').appendTo('body')
.css({ position: 'fixed', top: -1000000, left: -1000000 })
.val(text)
// Remove from DOM on unfocus
.focusout(function() { $(this).remove(); })
.select();
}
Modified