Thursday, 7 March 2013

HTML5: telephone numbers on web pages


Every day on TV we hear news saying that most of the people in the world is surfing the web using a mobile device. You are probably reading this very article with your iPhone or Galaxy, or maybe using your favourite tablet.
As many of the above mobile devices are actually capable of making phone calls, we can insert telephone numbers on web page and make them clickable, so that any mobile user will be able to use the link to call the shown number.

The way to do it is quite simple. In fact we can use a normal <a> tag with the tel protocol:
<a href="tel:+XX0123456789">Click to Call +XX0123456789</a>
Consider that instead of XX we need to put the country code (for example 39 for Italy). That is because our web page will be seen by people all over the world and not only from our country.

At the same time it is possible to pause the dialling by inserting p characters (each p a delay of one second). We can use w characters when we need to wait for a tone.

When we are browsing the page from a desktop computer, the link will not appear as clickable, unless the pc itself is ready to make phone calls through specific software.

As we use the tel protocol, we can use the fax protocol for fax numbers.
And last but not least, Skype uses the callto protocol, so we should be careful and use a way to detect the user agent and propose one or the other protocol according to the user device.

0 thoughts:

Post a Comment

Comments are moderated. I apologize if I don't publish comments immediately.

However, I do answer to all the comments.