1

I wanna create a chrome extension that when you click it that you open my website. But how? I tried searching on google but this is all what I could create:

{
  "name": "My First Extension",
  "version": "1.0",
  "description": "The first extension that I made.",
  "browser_action": {
    "default_icon": "icon.png"
    chrome.tabs.create({'url': chrome.extension.getURL('popup.html')}, function(tab) {
        // Tab opened.
    });
  },
  "permissions": [
    "http://api.flickr.com/"
  ]
}

But this doesn't seem to work.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Thew
  • 15,789
  • 18
  • 59
  • 100
  • 2
    possible duplicate of [Google Chrome Extensions - Open New Tab when clicking a toolbar icon](http://stackoverflow.com/questions/3188384/google-chrome-extensions-open-new-tab-when-clicking-a-toolbar-icon) – bzlm Feb 13 '11 at 13:38

2 Answers2

1

The bit of code,

chrome.tabs.create({'url': chrome.extension.getURL('popup.html')}, function(tab) {
    // Tab opened.
});

cannot be used directly in the manifest. If you look at the documentation for how to use browser actions, the correct way of handling the click event is to put something like this in the JavaScript on your background page:

chrome.browserAction.onClicked.addListener(function() {

    chrome.tabs.create({'url': chrome.extension.getURL('popup.html')}, function(tab) {
        // Tab opened.
    });

});

From your manifest, it looks like you don't have a background page. Simply create an HTML file with some JavaScript in it, and reference it in the manifest like so:

"background_page" : "background.html"
Matt
  • 385
  • 1
  • 5
0
{"manifest_version": 2,"name": "my app","version": "2.0","description": "This is a chrome extension for my app","browser_action": {"default_icon": "icon.png","default_popup": "popup.html"},"permissions": ["www.bibsoblog.blogspot.com"]}

If you want create a extention to go to your website by clicking the extension, and just use this code here click this to add that code to your popup.html.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
Solomon david
  • 82
  • 1
  • 3
  • 11