Skip to content

Instantly share code, notes, and snippets.

@markelog
Created May 3, 2012 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markelog/2589514 to your computer and use it in GitHub Desktop.
Save markelog/2589514 to your computer and use it in GitHub Desktop.
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