La extensión de Chrome no funciona

I have used the following code to open the current page URL in Rich Snippet Testing Tool. The problem is this that the extension works fine on first click and open the URL. But if the Testing page URL is currently open it will not allow to open another one.

My requirement is to open several pages at a time in Testing Tool with the help of this extension. But i am able to open only one at a time.

My Manifest File:

  "name": "RS Analyzer",
  "description": "Extension to get current page URL and display its Rich Snippets.",
  "version": "1.4",
  "background_page": "background.html",
  "permissions": [
    "tabs", "http://*/*", "https://*/*"
  "icons":{"16": "images/R_icon_16x16.jpeg",
           "48": "images/R_icon_48x48.jpeg",
          "128": "images/R_icon_128x128.jpeg"},
  "browser_action": {
      "default_title": "RS Analyzer",
      "default_icon": "images/icon.jpg"

Mi página de antecedentes:

    chrome.tabs.getSelected(null,function(tab) {
    var tablink = tab.url;
    var richurl = "" + encodeURIComponent(tablink) + "&view=";,'_newtab');

preguntado el 08 de noviembre de 11 a las 12:11

2 Respuestas

It's because you gave the window (tab) a name. This means that the same tab is used each time. It's like an identifier of the tab.

You can solve this by removing the name:;

respondido 08 nov., 11:16

Chrome doesn't understand "_newtab", it only considers it as an id for the tab so it will open the next one to the same tab. Using "_blank" will normally open new tab but it depends on user's settings (it may also open new window).

If you want new tab you should probably look into Chrome Extension tabs api. They have a método de creación there. It'll require you to set the permissions for the extension.

respondido 08 nov., 11:16

create method will create the tab at the end of tabs, i needed that tab to be opened adjacent to the input tab. It can be done by just removing _newtab. Thanks - Saurabh Saxena

@Chaitneya create() toma index as an argument that allows you to set the position of the tab. - Lycha

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.