Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1131659 of runtime.getBrowserInfo()

  • Revision slug: Mozilla/Add-ons/WebExtensions/API/runtime/getBrowserInfo
  • Revision title: runtime.getBrowserInfo()
  • Revision id: 1131659
  • Created:
  • Creator: wbamberg
  • Is current revision? No
  • Comment

Revision Content

{{AddonSidebar()}}

Returns information about the current platform.

Syntax

chrome.runtime.getBrowserInfo(
  function(browserInfo) {...} // function
)

This API is also available as browser.runtime.getBrowserInfo() in a version that returns a promise.

Parameters

callback
function. The function is passed the following arguments:
browserInfo
An object with the following properties:
  • name: string value representing the browser name, for example "Firefox".
  • vendor: string value representing the browser's vendor, for example "Mozilla".
  • version: string representing the browser's version, for example "51.0" or "51.0a2".
  • buildID: string representing the specific build of the browser, for example "20161018004015".

Browser compatibility

{{WebExtBrowserCompat}}

Examples

Get and log the browser's name:

function gotBrowserInfo(info) {
  console.log(info.name);
}

chrome.runtime.getBrowserInfo(gotBrowserInfo);

{{WebExtExamples}}

Acknowledgements

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Revision Source

<div>{{AddonSidebar()}}</div>

<p>Returns information about the current platform.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox brush:js">
chrome.runtime.getBrowserInfo(
  function(browserInfo) {...} // function
)
</pre>

<p>This API is also available as <code>browser.runtime.getBrowserInfo()</code> in a <a href="/en-US/Add-ons/WebExtensions/Using_the_JavaScript_APIs#Callbacks_and_promises">version that returns a promise</a>.</p>

<h3 id="Parameters">Parameters</h3>

<dl>
 <dt><code>callback</code></dt>
 <dd><code>function</code>. The function is passed the following arguments:</dd>
 <dd>
 <dl class="reference-values">
  <dt><code>browserInfo</code></dt>
  <dd>An object with the following properties:</dd>
  <dd>
  <ul>
   <li><strong><code>name</code></strong>: string value representing the browser name, for example "Firefox".</li>
   <li><strong><code>vendor</code></strong>: string value representing the browser's vendor, for example "Mozilla".</li>
   <li><strong><code>version</code></strong>: string representing the browser's version, for example "51.0" or "51.0a2".</li>
   <li><strong><code>buildID</code></strong>: string representing the specific build of the browser, for example "20161018004015".</li>
  </ul>
  </dd>
 </dl>
 </dd>
</dl>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>

<p>{{WebExtBrowserCompat}}</p>

<h2 id="Examples">Examples</h2>

<p>Get and log the browser's name:</p>

<pre class="brush: js">
function gotBrowserInfo(info) {
  console.log(info.name);
}

chrome.runtime.getBrowserInfo(gotBrowserInfo);</pre>

<p>{{WebExtExamples}}</p>

<div class="note"><strong>Acknowledgements</strong>

<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p>
</div>
Revert to this revision