mozilla

Revision 37224 of Services.jsm

  • Revision slug: JavaScript_code_modules/Services.jsm
  • Revision title: Services.jsm
  • Revision id: 37224
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment page created, 106 words added

Revision Content

{{ gecko_minversion_header("1.9.3") }}

The Services.jsm JavaScript code module offers a wide assortment of lazy getters that simplify the process of obtaining references to commonly used services.

To use it, you first need to import the code module into your JavaScript scope:

Components.utils.import(resource://gre/modules/Services.jsm);

Then you can obtain references to services by simply accessing them from the Services object exported by the code module. For example, to obtain a reference to the preferences service:

var prefsService = Services.prefs;

Provided service getters

Service Accessor Service Name
prefs Preferences service
appinfo Application information service
   

See also

Revision Source

<p>{{ gecko_minversion_header("1.9.3") }}</p>
<p>The <code>Services.jsm</code> JavaScript code module offers a wide assortment of lazy getters that simplify the process of obtaining references to commonly used services.</p>
<p>To use it, you first need to import the code module into your JavaScript scope:</p>
<pre class="eval"><span class="nowiki">Components.utils.import(resource://gre/modules/Services.jsm);</span></pre>
<p>Then you can obtain references to services by simply accessing them from the <code>Services</code> object exported by the code module. For example, to obtain a reference to the preferences service:</p>
<pre class="brush: js">var prefsService = Services.prefs;
</pre>
<h2>Provided service getters</h2>
<table class="standard-table" style="width: auto;"> <tbody> <tr> <td class="header">Service Accessor</td> <td class="header">Service Name</td> </tr> <tr> <td><code>prefs</code></td> <td>Preferences service</td> </tr> <tr> <td><code>appinfo</code></td> <td>Application information service</td> </tr> <tr> <td> </td> <td> </td> </tr>  </tbody>
</table>
<h2>See also</h2>
<ul> <li><a class="internal" href="/en/JavaScript_code_modules/Using_JavaScript_code_modules" title="en/JavaScript code modules/Using
    JavaScript code
    modules">Using JavaScript code modules</a></li> <li><a class="internal" href="/en/JavaScript_code_modules" title="en/JavaScript code
    modules">JavaScript code modules</a></li>
</ul>
Revert to this revision