I need to build a web page for mobile devices. There\'s only one thing I still haven\'t figured out: how can I trigger a phone call through the click of text?
Is the
Essentially, use an element with an href attr pointing to the phone number prefixed by tel:. Note that pluses can be used to specify country code, and hyphens can be included simply for human eyes.
MDN Web Docs
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Creating_a_phone_link
The HTML
element (or anchor element), along with its href attribute, creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other URL.[…]
Offering phone links is helpful for users viewing web documents and laptops connected to phones.
IETF Documents
https://tools.ietf.org/html/rfc3966
The
telURI for Telephone NumbersThe "tel" URI has the following syntax:
telephone-uri="tel:"telephone-subscriber[…]
Examples
tel:+1-201-555-0123: This URI points to a phone number in the United States. The hyphens are included to make the number more human readable; they separate country, area code and subscriber number.
tel:7042;phone-context=example.com: The URI describes a local phone number valid within the context "example.com".
tel:863-1234;phone-context=+1-914-555: The URI describes a local phone number that is valid within a particular phone prefix.