How do I make my website read what the browser the incoming person is using?

Discussion in 'Web Development' started by FusionIntegration, May 4, 2011.

  1. FusionIntegration

    FusionIntegration New Member

    Joined:
    May 4, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Detecting user browser can also be done with client side script as well.
     
  3. pein87

    pein87 Active Member

    Joined:
    Aug 6, 2010
    Messages:
    173
    Likes Received:
    47
    Trophy Points:
    28
    Occupation:
    Web Dev
    Location:
    Limbo
    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:
    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:
    document.write(userSpecs.browserVersion);
    //show fall back which would be regexed through
    document.write(userSpecs.userAgent);
    show all plugins descriptions
    Code:
    var i = 0;
    
    for (i = 0; i < userSpecs.installedPlugins.length; i++)
    {
    document.write(userSpecs.installedPlugins[i].description + "<br />");
    }
     
    Last edited: May 9, 2011
    shabbir likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice