Browser/System Detection
CONTRIBUTOR: Shahjahan Alhassan - 21st Oct 2001

With multiple browsers on the market it is sometimes difficult to create a piece of code that works on all. Therefore by detecting the user's browser and/or system individual pieces of code can be written to work with each and the appropriate one used.

Code example
Your system information is listed below:


Steps
  • Insert the source code within the <HEAD> </HEAD> tags of your page.
  • The function, <SCRIPT>detect("value")</SCRIPT>, can then be used within your code to return the value you require.
  • Use the chart below to view which values can be found and what results will be returned.


  • Value Usage Possible Results
    Browser's name detect("browsername") explorer, netscape, aol, webtv, other
    Browser's version detect("browserversion") Browser version
    Platform's name detect("platformname") windows, mac, linux, unix, irix, sunos, hp-ux, webtv, other
    Platform's version (Windows only) detect("platformversion") 98, 95, 3,1, NT, other
    Number of plugins installed (Netscape only) detect("plugins") Number of plugins
    Check if plugin installed (Netscape only) detect("plugin","Name of plugin") true, false
    Is Java enabled detect("java") true, false
    Are cookies enabled (Windows only) detect("cookies") true, false, unknown
    Colour depth detect("colourdepth") 8, 16, 24, 32 (bit)
    Number of colours detect("colours") Number of colours
    Screen width detect("screenwidth") Number of pixels
    Available screen width detect("availablescreenwidth") Number of pixels
    Screen height detect("screenheight") Number of pixels
    Available screen height detect("availablescreenheight") Number of pixels
    Referrer detect("referrer") URL

    Source code  [Select all code]