Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you open Chrome extension options page from a web page?

My Chrome extension has a content script that uses the following to inject HTML into the page:

var optionsUrl = chrome.extension.getURL("src/options/options.html"); 
var content = '<a href="' + optionsUrl + '" target="_blank">Options</a>';

This produces:

 <a href="chrome-extension://gdocgfhmbfbbbmhnhmmejncjdcbjkhfc/src/options/options.html" target="_blank">Options</a>

When I click the link, it opens a new browser tab and nothing more.

If I paste the href attribute chrome-extension://gdocgfhmbfbbbmhnhmmejncjdcbjkhfc/src/options/options.html into the address bar, I see the options page for my Chrome extension displayed correctly.

  • Why doesn't the link work?
  • Is there some extra permission that I'm missing?
like image 260
dvdsmpsn Avatar asked Apr 08 '14 19:04

dvdsmpsn


1 Answers

In the manifest file insert:

"web_accessible_resources": ["src/options/options.html"],

more info see documentation.

like image 93
Skalár Wag Avatar answered Nov 15 '22 14:11

Skalár Wag