Skip to content

Instantly share code, notes, and snippets.

@andreasvirkus
Created December 1, 2015 16:07
Show Gist options
  • Save andreasvirkus/31038965c6b8e61bceb2 to your computer and use it in GitHub Desktop.
Save andreasvirkus/31038965c6b8e61bceb2 to your computer and use it in GitHub Desktop.
// Simple check so we could use a single button for different mobile OS-s
var operatingSystem, userAgentString = navigator.userAgent;
var link = $("#store");
if (userAgentString.indexOf("iPhone") > -1 || userAgentString.indexOf("iPod") > -1 || userAgentString.indexOf("iPad") > -1) {
operatingSystem = "iOS";
link.attr("href", "http://store.apple.com/us/browse/app");
} else if (/Android/.test(userAgentString)) {
operatingSystem = "Android";
link.attr("href", "https://play.google.com/store/apps?hl=en");
} else if (/Windows Phone/.test(userAgentString)) {
operatingSystem = "Windows Phone";
link.attr("href", "http://www.windowsphone.com/en-us/store");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment