Get the selected text of a web page in google chrome extension
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? var selection = window.getSelection(); var range = selection.getRangeAt(0); if (range) { var div = document