I am developing a Google Chrome extension. When a popup is clicked, I would like the input box present in the popup.html file to contain the selected text of the current webpage.
Example textbox:
<input id="searchBox" type="text" />
When text is selected in a webpage, the textbox should contain the selected word. I tried with chrome.extension.getBackgroundPage().getSelection() but it is not working.
There was a thread about this on google groups: how to get HTML code from selection?
You can use this in the console or in a plugin, either way.