• Skip to main content
  • Select language
  • Skip to search
MDN Web Docs
  • Technologies
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs / DOM
    • WebExtensions
    • MathML
  • References & Guides
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
B2G OS
  1. MDN
  2. Archive of obsolete content
  3. B2G OS
  4. B2G OS APIs
  5. MozContact
  6. MozContact.init()

MozContact.init()

In This Article
  1. Summary
  2. Syntax
    1. Parameters
  3. Example
  4. Specifications
  5. See also

This API is available on Firefox OS for privileged or certified applications only.

Summary

The init method is used to initialize the mozContact object using a configuration object.

Syntax

contact.init(param);

Parameters

param
A configuration object which properties are one or more of the properties allow for mozContact. Note that id, published and update will be ignored as they are automatically generated and overridden when the contact is stored.

Example

var contact = new mozContact();
contact.init({name: "John Doe", givenName: "John", familyName: "Doe"});
var request = navigator.mozContacts.save(contact);
request.onsuccess = function() {
   alert("Success saving contact. New contact ID: " + contact.id);
};
request.onerror = function() {
   alert("Error saving contact.");
};

Specifications

Specification Status Comment
Contacts Manager API
The definition of 'Contacts Manager API' in that specification.
Working Draft First Working Draft (unstable)
vCard Format Specification IETF RFC RFC 6350

See also

  • mozContact
  • ContactManager

Document Tags and Contributors

Tags: 
  • API
  • B2G
  • DOM
  • DOM Reference
  • Firefox OS
  • Method
  • Non Standard
  • Reference
  • Référence
  • WebAPI
 Contributors to this page: chrisdavidmills, Sebastianz, fscholz, jsx, kscarfone, PostaL
 Last updated by: chrisdavidmills, Feb 27, 2017, 2:08:40 AM
See also
  1. Contacts API
  2. Archive
  3. Events
    1. success
    2. error
    3. contactchange
  4. Related pages for Contacts API
    1. ContactManager
    2. MozContact
    3. MozContactChangeEvent