19

I'm designing a mobile page and am using the following (standard, I believe) code to make the phone dial a phone number.

<a href="tel:555-1234567" class="call"><img src="graphics/call-icon.gif" alt="call-icon" width="45" height="50"></a>

This works fine in android but Mobile Safari I get the following error:

Cannot Open Page
Safari cannot open the page because the address is invalid

Iolo
  • 2,142
  • 3
  • 16
  • 17

8 Answers8

15

Your mark-up is fine, and it works on my iPhone (3GS, running 4.3.5). It doesn't work on the iOS simulator (yep, there's the "Cannot Open Page - Safari cannot open the page because the address is invalid" error), but then I wouldn't expect it to, given that you can't make calls on it (either that or the older version of iOS is at fault).

Ben
  • 7,548
  • 31
  • 45
11

In your <head> put:

<meta name="format-detection" content="telephone=yes">

From Safari HTML Reference:

This Enables or disables automatic detection of possible phone numbers in a webpage in Safari on iOS. Syntax Discussion By default, Safari on iOS detects any string formatted like a phone number and makes it a link that calls the number. Specifying telephone=no disables this feature. Availability Available in iOS 1.0 and later. Support Level Apple extension.

chown
  • 51,908
  • 16
  • 134
  • 170
6

for a telephone number to work in Safari/iOS you need to format the telephone properly like it would be listed in an old ad.

<a href="tel:1-555-123-4567" class="call">
----- OR -----
<a href="tel:15551234567" class="call">
James Williams
  • 4,221
  • 1
  • 19
  • 35
  • Nope, still get the same error. I also added the meta taag from your answer chown to no avail. I've also tried the link set to tel:171 which is the standard voicemail number in Ireland. – Iolo Oct 10 '11 at 17:00
  • I appreciate the flexibility that this option provides, not to mention compatibility with Chrome on iOS. (Verified working for Chrome and Safari on iOS 10.2.1) This answer seems to have stood the compatibility test of time. – Chad Jun 18 '18 at 22:21
5

You may want to add target="_blank" in the hyperlink tag.

It works for me.

Read more about target="_blank" at this link

funkymushroom
  • 2,079
  • 2
  • 26
  • 39
ArchyBean
  • 51
  • 1
  • 1
1

If you still have a problem with your telephone number not showing up on safari i had the exact same problem, i picked up that if you do not use a web friendly font it will not display try and change your font for the number to Verdana or Arial. I used google web font which should be web friendly but even that broke my number.

Hope this works.

1
<a class="font-13 color-theme" onclick="window.open('tel:+84935002102');">Call</a>
0

The following worked for me, hope it helps.

<a href="javascript:void(0)" onclick="window.location='tel:8005555555'" class="call">800 555 5555</a>

It should work on both ios chrome and safari.

Muhammad Russell
  • 361
  • 4
  • 13
0

2021 Update here, I'm building an Ionic app for android and ios, and was having troubles getting the link for phones to work in safari, what I did that solved the issue was creatig a small utility function (typescript) that cleared the phone number of any characters this way:

cleanPhoneNumber(text: string): string {

    const cleanText = text.trim()
        // INITIAL CHAR
        .replace(/\+/g, '')
        // COMMON SEPARATORS
        .replace(/\-/g, ' ').replace(/\./g, ' ')
        // RARE CHARACTERS
        .replace(/\_/g, '').replace(/\,/g, '').replace(/\:/g, '').replace(/\;/g, '').replace(/\~/g, '');

    return cleanText;
}

Characters like "+" or "-" cause safari to not handle href:tel properly (despite Chrome or Firefox working fine with that)

Hope this helps somebody else that is new like me building apps for ios

Luis Santana
  • 1
  • 1
  • 4