clipboard

Using execCommand (Javascript) to copy hidden text to clipboard

橙三吉。 提交于 2019-11-26 09:36:47
问题 I\'m trying to copy to clipboard without using Flash, I plan to fall back onto Flash with the use of ZeroClipboard if the browser is incompatible with the javascript approach. I have an onClick listener for the button which looks like: $(buttonWhereActionWillBeTriggered).click(function(){ var copyDiv = document.getElementById(inputContainingTextToBeCopied); copyDiv.focus(); document.execCommand(\'SelectAll\'); document.execCommand(\"Copy\", false, null); } and an input field as follows:

Copy to clipboard without Flash

我是研究僧i 提交于 2019-11-26 09:07:48
问题 I found many solutions for copying to the clipboard, but they all either with flash, or for websites side. I\'m looking for method copy to clipboard automatically, without flash and for user side, it\'s for userscripts and of course cross-browser. 回答1: Without flash, it's simply not possible in most browsers. The user's clipboard is a security-relevant resource since it could contain things like passwords or credit card numbers. Thus, browsers rightly don't allow Javascript access to it (some

How do I copy the contents of a String to the clipboard in C#?

萝らか妹 提交于 2019-11-26 08:47:56
问题 If I have some text in a String, how can I copy that to the clipboard so that the user can paste it into another window (for example, from my application to Notepad)? 回答1: You can use System.Windows.Forms.Clipboard.SetText(...) . 回答2: System.Windows.Forms.Clipboard.SetText (Windows Forms) or System.Windows.Clipboard.SetText (WPF) 回答3: I wish calling SetText were that easy but there are quite a few gotchas that you have to deal with. You have to make sure that the thread you are calling it on

Copying text to the clipboard using Java

旧巷老猫 提交于 2019-11-26 08:47:25
问题 I want to copy text from a JTable \'s cell to the clipboard, making it available to be pasted into other programs such as Microsoft Word. I have the text from the JTable , but I am unsure how to copy it to the clipboard. 回答1: This works for me and is quite simple: Import these: import java.awt.datatransfer.StringSelection; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; And then put this snippet of code wherever you'd like to alter the clipboard: String myString = "This text

How to Copy Text to Clip Board in Android?

喜你入骨 提交于 2019-11-26 08:40:19
问题 Can anybody please tell me how to copy the text present in a particular textview to clipboard when a button is pressed? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mainpage); textView = (TextView) findViewById(R.id.textview); copyText = (Button) findViewById(R.id.bCopy); copyText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub

Why is document.execCommand(“paste”) not working in Google Chrome?

▼魔方 西西 提交于 2019-11-26 08:26:22
问题 I have a problem with my extension. I want to paste data from the clipboard. So far, I\'ve got this: function pasteAndGo() { document.execCommand(\'paste\') alert(\"Pasted\") } The alert comes up, but nothing has been pasted. I\'ve got a feeling it\'s the document part that needs changing, but I don\'t know what to do. Any ideas? 回答1: There used to be an experimental clipboard API in Chrome, but this was removed in Chrome 13. Chrome has moved towards the more standard document.execCommand(

Copy output of a JavaScript variable to the clipboard

我的未来我决定 提交于 2019-11-26 08:23:37
问题 I have no knowledge of JavaScript, but I managed to put this code together using bits and bolts from various Stack Overflow answers. It works OK, and it outputs an array of all selected checkboxes in a document via an alert box. function getSelectedCheckboxes(chkboxName) { var checkbx = []; var chkboxes = document.getElementsByName(chkboxName); var nr_chkboxes = chkboxes.length; for(var i=0; i<nr_chkboxes; i++) { if(chkboxes[i].type == \'checkbox\' && chkboxes[i].checked == true) checkbx.push

Copy to Clipboard for all Browsers using javascript

此生再无相见时 提交于 2019-11-26 08:07:09
问题 I was trying to make \"Copy to Clipboard\" work on all browsers but no luck. Am using javascript and I don\'t want to use Zero Clipboard to do. Please let us know what wrong in my code. Appreciate for your help. Below is the code (Currently my code is working only on IE browser):- <script type=\"text/javascript\"> function copyToClipboard(s) { if( window.clipboardData && clipboardData.setData ) { clipboardData.setData(\"Text\", s); } else { // You have to sign the code to enable this or allow

Copy to Clipboard in Chrome Extension

佐手、 提交于 2019-11-26 08:04:31
问题 I\'m making an extension for Google Chrome and I have hit a snag. I need to copy a readonly textarea\'s content to the clipboard on click in the popup. Does anyone know the best way to go about this with pure Javascript and no Flash? I also have jQuery loaded in the extension, if that helps any. My current (non-working) code is... function copyHTMLCB() { $(\'#lb_html\').select(); $(\'#lb_html\').focus(); textRange = document.lb_html_frm.lb_html.createTextRange(); textRange.execCommand(\

Access clipboard in Windows batch file

旧时模样 提交于 2019-11-26 07:35:43
问题 Any idea how to access the Windows clipboard using a batch file? 回答1: To set the contents of the clipboard, as Chris Thornton, klaatu, and bunches of others have said, use %windir%\system32\clip.exe . Update 2: For a quick one-liner, you could do something like this: powershell -sta "add-type -as System.Windows.Forms; [windows.forms.clipboard]::GetText()" Capture and parse with a for /F loop if needed. This will not execute as quickly as the JScript solution below, but it does have the