开发者

Please suggest how to write a text from webpage text box to clipboard

I have a text box in the webpage, a text in that text box i need that to be sent开发者_JAVA百科 to the clipboard of ubuntu how do i do that? I'm using python CGI, Please suggest me a link or Idea to proceed.

Thank you :)


Python and cgi run on the server, but you want to copy text from the webpage that a client is viewing to the client's clipboard.

Hence you have to do your solution client-side with javascript or a javascript library like jQuery. This used to be do-able using jQuery clipboard, though this was a security problem as rogue flash apps could arbitrarily alter the users clipboard (causing people to paste the wrong URL, etc). So, flash fixed the security hole that allowed client scripts to alter the clipboard whenever the script wanted, so up to date versions of flash can't alter the clipboard unless the user initiating the action with a click inside a flash movie.

However, http://code.google.com/p/zeroclipboard/ still works (requiring you to click a button before it can modify the clipboard), so you can use that. They have test pages and an wiki of instructions


Getting text from the ubuntu (assuming GNOME as desktop environment) clipboard into a python script can be done with

import  pygtk
import gtk
clipboard = gtk.clipboard_get()
print clipboard.wait_for_text()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜