Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
30
rated 0 times [  32] [ 2]  / answers: 1 / hits: 46488  / 10 Years ago, sat, june 28, 2014, 12:00:00

I will send my clients the link for the app in the following format



http://goo.gl.com/downloadtheapp (or whatever)



I want this file be somewhere on my server that includes java script code that checks what is the device type and redirects to the convenient store. that is, google play if the device was android based and appstore if the device was ios based.



till now I tried this, but it does not work.



<html>
<head>
<script type=text/javascript>
$(document).ready(function ()
{
if(navigator.userAgent.toLowerCase().indexOf(android) > -1)
{
window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
}
if(navigator.userAgent.toLowerCase().indexOf(iphone) > -1)
{
window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8';
}
}
</javascript>
</head>
<body>
</body>
</html>

More From » android

 Answers
44

The problem is with your script tag and you are missing );


And by the way, did you import jQuery?


<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>

<script>
$(document).ready(function (){
if(navigator.userAgent.toLowerCase().indexOf("android") > -1){
window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
}
if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){
window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8';
}
});
</script>

[#70393] Thursday, June 26, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hallie

Total Points: 503
Total Questions: 114
Total Answers: 103

Location: Iraq
Member since Fri, Jun 5, 2020
4 Years ago
;