MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

An Options page enables you to define preferences for your WebExtension that your users can change. Users can access the options page for an add-on from the browser's add-ons manager:

The way users access the page, and the way it's integrated into the browser's user interface, will vary from one browser to another.

You can open the page programmatically by calling runtime.openOptionsPage().

Options pages have a Content Security Policy that restricts the sources from which they can load resources, and disallows some unsafe practices such as the use of eval(). See Content Security Policy for more details.

Specifying the options page

To create an options page, write an HTML file defining the page. This page can include CSS and JavaScript files, like a normal web page. This page, from the favourite-colour example, includes a JavaScript file:

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
  </head>

<body>
  <form>
      <label>Favourite colour</label>
      <input type="text" id="colour" >
      <button type="submit">Save</button>
  </form>
  <script src="options.js"></script>
</body>

</html>

JavaScript running in the page can use all the WebExtension APIs that the add-on has permissions for. In particular, you can use the storage API to persist preferences.

Package the page's files in your add-on.

You also need to include the options_ui key in your manifest.json file, giving it the URL to the page.

"options_ui": {
  "page": "options.html",
  "browser_style": true
},

Examples

The webextensions-examples repo on GitHub contains several examples of WebExtensions that use an options page:

Document Tags and Contributors

Tags: 
 Contributors to this page: wbamberg, hellosct1, rebloor
 Last updated by: wbamberg,