I have a chrome extension with an options page. The options page works correctly and I can get to it from the extensions page, however I'd also like a link to it within the popup of my extension. Is this possible? It doesn't seem to have a url but is there a way to tell chrome to link to the extensions options?
3 Answers
New method since Chrome 42:
chrome.runtime.openOptionsPage()
will open the options, regardless of whether new-style embedded options or old-style options page is used.
chrome.runtime.openOptionsPage()
will always open the canonical location, and has nice behavior like re-focusing an open options page if there is one.

- 74,770
- 16
- 179
- 206
-
Thanks for pointing this out! I was about to run into the incorrect documentation about the new style of options. – Erik Gillespie May 06 '15 at 14:13
-
It's so strange that the documentation server did not pick up the documentation update (which is already in the codebase) for 3 weeks. I pinged kalman about it. – Xan May 06 '15 at 14:16
-
Worth noting is that this doesn't seem to work from embedded elements like buttons. – Brad Johnson Jan 05 '18 at 22:51
-
@BradJohnson Perhaps you're trying to use inline `onclick`, which is not allowed. – Xan Jan 05 '18 at 22:52
-
I built the button using document.createElement and attached click event listener. No joy. – Brad Johnson Jan 06 '18 at 22:59
-
@BradJohnson If that's UI injected by a content script, then indeed `chrome.runtime.openOptionsPage()` is not available from the content script context. Alternatively, you may be using a `submit` button. – Xan Jan 06 '18 at 23:06
You can have Chrome open your extension's options page in a new tab using something like this:
chrome.tabs.create({'url': "/options.html" } )
Much like HTML, the URL is considered relative to the calling page, but you can use a forward slash to load a page that is relative to the extension's root.
update:
If you want to open the options page from content-script you have to use this method: How do you open Chrome extension options page from a web page?
-
I'm getting `Uncaught TypeError: Cannot call method 'create' of undefined` in a **[content script](https://developer.chrome.com/extensions/content_scripts)**. Looks like [I can't do that](http://stackoverflow.com/questions/15034859/chrome-tabs-returns-undefined-in-content-script). I also can't upvote you unless the answer is edited again. – dvdsmpsn Apr 08 '14 at 19:33
-
You can send a message from your content script to a background page if you want to avoid adding web accessible resources to your manifest file. Using messages is probably more in line with how extensions were originally designed. – Nilpo Feb 20 '15 at 00:55
You can use a relative link directly in the html:
<a href="options.html" target="_blank">Options</a>

- 26,167
- 10
- 55
- 67
-
6This wont work, especially if this has been embedded in into a webpage. At that point it take the default domain and prefixes it to options.html. Ex: `localhost/options.html` You want `Chrome-extension://sfj2jngijnei2f9b2f9bbkbe/options.html` which can only be obtained via the chrome API. chrome.extension.getURL('options.html') – Rizowski Jan 09 '14 at 03:55