1

So I'm trying to make an extension that on click opens a tab and goes to a page. The only thing I can make it do so far is open a tab and give me this error:

No webpage was found for the web address: chrome-extension://hgjkkhjinhilcehaaldcnopaefinlfif/https://www.google.com/

Here is the manifest.json:

{
  "name": "New App",
  "version": "0.1",
  "permissions": ["tabs"],
   "manifest_version": 2,     
  "browser_action": {
   "default_icon": "icon.png"
  },
  "background": {
    "scripts": ["background.js"]
  },
  "icons": {
    "48": "icon.png"
  }
}

Here is background.js

chrome.browserAction.onClicked.addListener
    (function(tab) 
        {chrome.tabs.create({'url': chrome.extension.getURL('https://www.google.com/')}, function(tab) {})
        }                                    
    )
devhl
  • 111
  • 1
  • 9
  • Where did you get this incorrect manifest code? I've seen the mistake before: `background_page` is a property of the root element, not of `browser_action`. Besides, `background_page` has been replaced with `"background"`, see http://code.google.com/chrome/extensions/background_pages.html. – Rob W Aug 06 '12 at 12:26
  • Thanks, I've made some progress. I can open a tab now! [code] { "name": "New App", "version": "0.1", "permissions": ["tabs"], "browser_action": { "default_icon": "icon.png", "background": "background.html" }, "background": { "scripts": ["background.js"] }, "icons": { "48": "icon.png" }, "manifest_version": 2 }[/code] [code]chrome.browserAction.onClicked.addListener(function(tab) { chrome.tabs.create({'url': chrome.extension.getURL('page.html')}, function(tab) { }); });[/code] – devhl Aug 07 '12 at 02:54
  • Here's Google's response though:
    No webpage was found for the web address: chrome-extension://hgjkkhjinhilcehaaldcnopaefinlfif/page.html
    
    
    Please excuse my ignorance with code blocks on this site.
    Also, how do I post code in the comments?  [code] doesn't work here.
    – devhl Aug 07 '12 at 02:58
  • `test` @Rob
    test
    – devhl Aug 07 '12 at 03:09
  • Update your question, and insert the code. Select it and press Ctrl+K, then each line will be prefixed with four spaces (or, if you're selecting only a part of a line, surrounded in backticks). This marks a code block. Regarding Not found: Are you sure that the file exists? – Rob W Aug 07 '12 at 05:45
  • Is the URL **really** set to `https://google.com/`? If yes, see http://stackoverflow.com/a/9586857. – Rob W Aug 07 '12 at 11:56
  • possible duplicate of [How i load a webpage in a popup chrome extension without iframe and using ajax](http://stackoverflow.com/questions/9585163/how-i-load-a-webpage-in-a-popup-chrome-extension-without-iframe-and-using-ajax) – Rob W Aug 08 '12 at 09:34

1 Answers1

1

What I was trying to do was open a new tab and go to a website in the browser action. Here is the answer:

Manifest.json

{ "name": "Funny Pictures",
  "version": "0.1",
  "manifest_version": 2, 
  "description": "Rick Roll all your friends!",
  "browser_action": {
        "default_icon": "funnyface.png"
  },
  "icons": {
            "48": "funnyface.png"
            },
    "background":{
                    "scripts": ["background.js"]
    }
}

background.js

chrome.browserAction.onClicked.addListener(function(activeTab) {
    var newURL = "http://www.youtube.com/watch?v=oHg5SJYRHA0";

    chrome.tabs.create({ url: newURL });
});

I swear I tried this previously, but that's how it goes I guess.

devhl
  • 111
  • 1
  • 9