How to detect which type of browser is being used
(and browser capabilities)
It is actually incredibly easy to establish which browser is being used using JavaScript. It is simply:
navigator.appName
This typically returns 'Microsoft Internet Explorer', 'Netscape' or the name of some other browser if it is something other than Internet Explorer or Netscape.
So your browser is:
However, knowing the type of browser is not as useful as knowing what features the browser supports. The following table lists some of the common data items to test:
document.images |
Use to test if the browser supports images. Defined if the browser supports images, undefined if it does not support images. |
document.layers |
Use to test if the browser supports layers. Defined if the browser supports layers, undefined if it does not. |
document.all |
Use to test if the browser supports Dynamic HTML (DHTML). Defined if the browser supports DHTML, undefined if it does not. |
document.frames |
Use to test if the browser supports frames. Defined if the browser supports frames, undefined if it does not. |
document.filters |
Use to test if the browser supports Microsoft transition effects. In practise only Internet Explorer supports transition effects. |
For example:
if (document.images) document.write('Browser supports images') else document.write('Browser does not support images);