0

I need a little bit of help here. I need help with a script. I try:

<script language=javascript>
<!--
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
    location.replace("http://url-to-send-them/iphone.html");
}
-->
</script>

But is not working as I expected. I need to redirect to different stores if I go to one URL example. If i go to: www.mydomain.com.ar/app and I use an Android Phone I need to redirect my browser to the Android Play Store. If I go to www.mydomain.com.ar/app and I use iOS I need to redirect to the App Store. How can i do this? I dont have the knowledge so if you can help me will be great. Thank you so much.

Milo
  • 3,002
  • 9
  • 25
  • 40

1 Answers1

0

This should work.

var isMobile = {
    Android: function() {
        return /Android/i.test(navigator.userAgent);
    },
    iOS: function() {
        return /iPhone|iPad|iPod/i.test(navigator.userAgent);
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
    }
};