December 15, 201510 yr Is there a way where when my website has been viewed through mobile, can it detect an app and so that it can be downloaded and viewed? For example Android an app for the website will appear showing that the android app is available to download the app a bit like http://www.buzzfeed.com/ if you go to a mobile is gives you an app dowload? Edited December 15, 201510 yr by Vulcan
December 15, 201510 yr Yes when a browser sends a request to a server it (usually) identifies itself with a user agent string sent along with the request. The user agent string contains information about what browser and operating system is used. The string can be accessed with server side code but it is also stored in the JavaScript window object's property navigator.userAgent . To detect Android devices you would simply search for a match for the word "Android" in the string if(navigator.userAgent.indexOf('Android') > -1){ /*Android OS detected now do your thing*/ }
Create an account or sign in to comment