ContactAddress
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only insecure contexts (HTTPS), in some or allsupporting browsers.
Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.
TheContactAddress interface of theContact Picker API represents a physical address. Instances of this interface are retrieved from theaddress property of the objects returned byContactsManager.getProperties().
It may be useful to refer to the Universal Postal Union website'sAddressing S42 standard materials, which provide information about international standards for postal addresses.
In this article
Instance properties
ContactAddress.addressLineRead onlyExperimentalAn array of strings providing each line of the address not included among the other properties. The exact size and content varies by country or location and can include, for example, a street name, house number, apartment number, rural delivery route, descriptive instructions, or post office box number.
ContactAddress.countryRead onlyExperimentalA string specifying the country in which the address is located, using theISO-3166-1 alpha-2 standard. The string is always given in its canonical upper-case form. Some examples of valid
countryvalues:"US","GB","CN", or"JP".ContactAddress.cityRead onlyExperimentalA string which contains the city or town portion of the address.
ContactAddress.dependentLocalityRead onlyExperimentalA string giving the dependent locality or sublocality within a city, for example, a neighborhood, borough, district, or UK dependent locality.
ContactAddress.organizationRead onlyExperimentalA string specifying the name of the organization, firm, company, or institution at the address.
ContactAddress.phoneRead onlyExperimentalA string specifying the telephone number of the recipient or contact person.
ContactAddress.postalCodeRead onlyExperimentalA string specifying a code used by a jurisdiction for mail routing, for example, the ZIP code in the United States or the PIN code in India.
ContactAddress.recipientRead onlyExperimentalA string giving the name of the recipient, purchaser, or contact person at the address.
ContactAddress.regionRead onlyExperimentalA string containing the top level administrative subdivision of the country, for example a state, province, oblast, or prefecture.
ContactAddress.sortingCodeRead onlyExperimentalA string providing a postal sorting code such as is used in France.
Instance methods
ContactAddress.toJSON()ExperimentalA standard serializer that returns a JSON representation of the
ContactAddressobject's properties.
Examples
The following example prompts the user to select contacts, then prints the first returned address to the console.
const props = ["address"];const opts = { multiple: true };async function getContacts() { try { const contacts = await navigator.contacts.select(props, opts); const contactAddress = contacts[0].address[0]; console.log(contactAddress); } catch (ex) { // Handle any errors here. }}Specifications
| Specification |
|---|
| Contact Picker API> # contactaddress> |