Created
May 3, 2012 21:06
-
-
Save markelog/2589514 to your computer and use it in GitHub Desktop.
Copy in Firefox, Chrome and Safari
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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