When iOS interprets data as phone numbers
While developing an mobile website that used geolocation, I noticed that long latitude numbers on screen changed into links. At first I thought it was a jQuery error, but the problem persisted without any JavaScript at all.
- I discovered that appending letters, a–z, prevented the problem.
- The problem occured in the iPhone simulator, but not desktop Safari.
- I tried
<meta name="format-detection" content="telephone=no" />from Apple’s meta tag reference. No luck. - I tried converting the number to a string in JavaScript. Still no luck.
- I could work around the issue by styling my links to resemble text, but who wants to sacrifice user interface for a hack?
Solution
Turns out that iOS on iPhones, simulated or not, always tries to read certain strings as phone numbers. We appended ° to the end of each latitude and longitude numbers, and it worked.
Tags: iOS problem solving