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"
}
}
My Background Page:
chrome.browserAction.onClicked.addListener(function(tab){
chrome.tabs.getSelected(null,function(tab) {
var tablink = tab.url;
var richurl = "http://www.google.com/webmasters/tools/richsnippets?url=" + encodeURIComponent(tablink) + "&view=";
window.open(richurl,'_newtab');
});
});
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: