google chrome extension - Replacing user selected text in Javascript -


It was Google for a while and it seems really simple, but I can not exclude this issue . I have a Chrome extension, where you select some text, you right click and there is a button that makes some calculations on the selection. But for some reason, I can not reveal the selection in a warning window.

  if (window.getSelection) {window.alert ("what is entered if window.getselection"); Sel = window.getSelection (); Window.alert (SEL); }   

So if this enters the statement, first displays the warning, then the second warning is empty. My mind is trying to do this work, it feels like it will be so easy that I can remember it. Besides, what would be the best way to change the selected text? Thank you. Edit: You wanted to see my manifest file. "" Name ":" Convert "," Details ":" Laurem "," Version ":" 0.6 "," Permissions ": [" I thought "context menu", "tab", "windows" "," background ": {" script ": [" conversion.js "]}," manifest_version ": 2}

I have done something wrong, I am a greenhorn when I come into Chrome Extension.

You start at the Chrome extension So, take a look at this.

If you , You'll be back enlightened that the background code runs on a different page, and references it to the window and not currently open and visible tabs to access it For this, you normally need some sort of thing.

But before you start implementing the content script , take a look at this.

receives an information object, which is un Among other things, selectionText with the selected text invites the context menu. If you do not want all (and the full select objects), then you do not need to interact on the page at all:

  Function HandContacts (Information) {If (Something was selected, stuff with it}}   

If you need a full selection object, this is the minimum code for this (< Code> Active tab permission):

  Function HandContacts (information, tab) {if (tab) {chrome.tabs.executeScript (tab.id, {Code: "window.getSelection ();"}, function (results) {// do something with the results [0]}); }}   

See and refer to.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -