Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dealing with tel: anchor

I have an anchor to a telephone number. On phones is great. On desktops with Skype or Google Voice it's good. The problem is on desktops that just don't know how to deal with that.

What should I do? Detect if it's not mobile and change the link? I still want the link to show, just the URL to be different.

Is there a better way? If not, how do I detect mobile in JavaScript in order to change the href attribute?

Thank you.

like image 407
Francisc Avatar asked Oct 24 '22 09:10

Francisc


1 Answers

To detect if the browser is launching from a mobile in JavaScript: http://detectmobilebrowser.com/

Then you can detect a phone number in JavaScript using a regular expression, such as one of those: http://www.regxlib.com/DisplayPatterns.aspx?cattabindex=6&categoryId=7

And finally rewrite the link: aLink.href="..."

The web-browser is responsible for launching the associated application for a certain link and I guess skype is registering for the phone numbers in the desktop. You can't do anything from the web-page I'm afraid.

like image 133
jonjbar Avatar answered Oct 30 '22 15:10

jonjbar