0

I'm making a webpage that has links to my various social media pages. I want it that when the user clicks the link, if the user has the app for that social site, the link opens the app and if not it goes to it's web page.

So for example (I'll use the link to my Instagram page): If the user has the Instagram app on their device the href in the <a> tag will be instagram://user?username=USERNAME and if the app isn't on the device the href would be http://instagram.com/USERNAME. Does anyone know how I can do this, preferably using JavaScript? I'm considering window.navigator but I'm hoping there's a better way seeing as that just tells me what device/OS the user is using. I also want to do this for Twitter and Tumblr.

cbender
  • 2,231
  • 1
  • 14
  • 18
  • possible duplicate of [iPhone apps: Can I open an app from a link in a website?](http://stackoverflow.com/questions/2095638/iphone-apps-can-i-open-an-app-from-a-link-in-a-website) – Jasper Jul 26 '15 at 20:11
  • 1
    @Jasper It's not a duplicate. I'm not asking if there's a link that can open the app. I'm asking that if the app doesn't exist can the link open the webpage instead. – cbender Jul 26 '15 at 20:18
  • @Jasper that one asks how to enable doing so _in the app_ whereas this one asks how to actually do it _in the website_ – Noobification Jul 26 '15 at 20:23
  • It's not, the question is: "Can I open an app from a link in a website?" According to [this answer](http://stackoverflow.com/a/2095662/1282144) you can use URI Schemes to start an app from a link on a website, but they won't work if the app is not installed. I don't think there is a way to check for the existence of an app from within your webpage, so you;ll have to provide separate links (like 'open in browser' and 'open in app'). – Jasper Jul 26 '15 at 20:29

0 Answers0