hyperlink on click - goes to correct app store

i have a web page that has a hyperlink on it that says "click to download app" or some such thing... and when a mobile user clicks on it - i need to redirect to either the Android Store or the Apple App Store... how do i do this?
Who is Participating?
nap0leonConnect With a Mentor Commented:
Perhaps you want something like this:
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {
  // Redirect to Android-store
  window.location = 'Your Android Store URL Here';
  // Redirect to Apple-store
  window.location = 'Your Apple Store URL Here';

Open in new window

quigleyryanAuthor Commented:
thanks what's the Javascript to choose which one to go to? i really only want one page that the onclick determines which appstore to redirect to.
quigleyryanAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.