Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Web Development (http://www.go4expert.com/forums/web-development-forum/)
-   -   How do I make my website read what the browser the incoming person is using? (http://www.go4expert.com/forums/i-website-read-browser-incoming-person-t25703/)

FusionIntegration 5May2011 01:38

How do I make my website read what the browser the incoming person is using?
 
I need to code in whatever language, so that my website can see what browser the user is using and play either a flash, quicktime, or html5 video based on whatever browser that user is visiting my site with.

Thanks,

Patrick

shabbir 5May2011 07:02

Re: How do I make my website read what the browser the incoming person is using?
 
Detecting user browser can also be done with client side script as well.

pein87 9May2011 09:09

Re: How do I make my website read what the browser the incoming person is using?
 
Hey use this code. Add it to a blank .js file amd include it in your page. Then just call one of the objects for the info you want. You'll need to perform a loop to see what is what from the plugins though. I did test this code in chorme so just a heads up userCpu doesn't work in it. You may need to write a function using regex for a flash version. Try my below code for plugins in your browser to see how its set up though first. If you compress the code it'll be an uber tiny library for user specs on the client end.


Code: JavaScript

var userSpecs =
{
browserVersion : navigator.appVersion,
browserName : navigator.appName,
cookiesEnabled : navigator.cookieEnabled,
userAgent : navigator.userAgent,
systemLanguage : navigator.systemLanguage,
userLanguage : navigator.userLanguage,
installedPlugins : navigator.plugins,
userOS : navigator.platform,
mimeTypes : navigator.mimeTypes,
browserCodeName : navigator.appCodeName,
javaEnabled : navigator.javaEnabled,
taintEnabled : navigator.taintEnabled,
userCpu : navigator.cpuClass
};


show browser version
Code: JavaScript

document.write(userSpecs.browserVersion);
//show fall back which would be regexed through
document.write(userSpecs.userAgent);


show all plugins descriptions
Code: JavaScript

var i = 0;

for (i = 0; i < userSpecs.installedPlugins.length; i++)
{
document.write(userSpecs.installedPlugins[i].description + "<br />");
}



All times are GMT +5.5. The time now is 02:15.