Using <a>
tag and window.location(), how to open the android app when the link is clicked else use the browser.
For example, i have the facebook link: fb://profile/10001901208 and https://www.facebook.com/profile.php?id=10001901208.I tried onclick() method but it seems to work differently.
<script>
window.onload = function() {
if(navigator.userAgent.match(/iPhone|iPad|iPod/i)) {
window.location = "<TWITTER MOBILE DEEPLINK>";
setTimeout(function(){
window.location = "<LINK TO TWITTER ONLINE>";
}, 50);
} else {
window.location = "<LINK TO TWITTER ONLINE>";
}
}
</script>
I tried @media screen and hide and show the tag but it didnt work as expected. Since it is predetermined, if the app is not installed it says; Page couldnt load.
<a href="fb://profile/10001901208" target="_blank" class="mobile"><li class="fa fa-facebook"></li></a>
<a href="https://www.facebook.com/profile.php?id=10001901208" target="_blank" class="web"><li class="fa fa-facebook"></li></a>
I expect the output of opening the app if installed else open in the browser using window.location() and if possible with <a>
tag.
You need to find out if the user is using a cell phone, or a computer.
This is how I do it.
In your body do this.
And then in your HTML, add a div for the links.