Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialGrant Bates
1,915 PointsLooking to create a link that will recognize device and send to the proper app store.
I have been searching around the web for a simple and lightweight piece of code that will recognize the device being used and send the user to the proper app store.
I feel like this is a pretty common bit of coding but for the life of me I can't find a tutorial. Any help would be appreciated.
I would prefer to just use HTML5 and CSS if possible but a little javascript would kill me. (I don't know much about scripting.)
If you don't have the answer but know where I might find one please share.
Thank you.
So far I have this going for me...
var ua = navigator.userAgent;
if (ua.indexOf("Android")>-1) {
// generate play store link
} else if (ua.indexOf("iPad")>-1 || ua.indexOf("iPhone")>-1) {
// generate ios link
} else if (ua.indexOf("Windows Phone")>-1) {
// generate windows store link
}
But I don't know how to incorporate with the HTML
1 Answer
xyraine
1,669 PointsHi Grant,
You might be interested in reading more into to filtering user agents. The best way would have to be through JS. I would do a search for "How to detect user agent using javascript".
I'm not an expert yet but I hope this helps! Ryan
Grant Bates
1,915 PointsGrant Bates
1,915 PointsThanks. I am finding lots of references to identify the device but not a lot on what to do after the fact.