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.