Skip to content

Instantly share code, notes, and snippets.

@hawkapparel
Created September 2, 2016 16:53
Show Gist options
  • Save hawkapparel/22f2f72f522540814fc4e66e8de29d57 to your computer and use it in GitHub Desktop.
Save hawkapparel/22f2f72f522540814fc4e66e8de29d57 to your computer and use it in GitHub Desktop.
// by default it takes ua string from current browser's window.navigator.userAgent
var parser = new UAParser(),
result = parser.getResult();
if(result.device.type == undefined) {
console.log('PC');
window.location.href = "http://www.movistar.com.pe/hogar/tv/gol-peru-cmd/-/tab/app-futbol-movistar";
}
else if(result.device.type == 'mobile' || result.device.type == 'tablet') {
console.log('Mobile/Tablet');
if(result.os.name == 'iOS') {
console.log('iOS');
window.location.href = "https://itunes.apple.com/pe/app";
}
else if(result.os.name == 'Android') {
console.log('Android');
window.location.href = "https://play.google.com/store/apps/details";
}
else {
console.log('Fallback OS');
window.location.href = "https://www.google.com.pe/";
}
}
else {
console.log('Fallback Device');
window.location.href = "https://www.google.com.pe/";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment