Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Copy in Firefox, Chrome and Safari
// We can't copy stuff in clipboard in Chrome, Safari and Firefox (Opera)
// Maybe one day this tickets will be resolved –
// https://bugzilla.mozilla.org/show_bug.cgi?id=407983
// https://bugs.webkit.org/show_bug.cgi?id=17645
// But if they will, we still can only copy text to clipboard only during clipboard events
// We might get around this, it's not a production code, just...
var clipboard = function() {};
// If we have firebug installed
if ( console.notifyFirebug ) {
clipboard = function( text ) {
console.notifyFirebug( [ text ], "copy", "firebugExecuteCommand" );
}
}
// It also gives us event in Safari and Chrome for keyup in console
console.__defineSetter__( "_commandLineAPI", function( api ) {
clipboard = api.copy;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.