Which Browser - January 2010
I needed to determine which browser the client was using. I searched the web and found some useful code. I encapsulated it into a class module called cWhichBrowser. It becomes the tip-of-the-month.
2010/02/16 - I added support for Safari and modified the Chrome check. Request.UserAgent is used to distinguish between Safari and Chrome. I also added browser property IsMobileDevice. I am starting to do some development for the iPhone/iPod Touch and needed to know if the mobile version of Safari we being used by the client.
2011/04/18 - Added support for IE9. If you downloaded a prior version you should download this one. See below.
2011/06/09 - Added support for the iPad and iPhone. Methods IsIPad and IsIPhone are added. Tested with the iPad. Not tested with the iPhone. I found the inspiration for this via Google. Click here to view that inspiration.
2016/12/13 - Added support for Microsoft's Edge browser.
VB.Net Demo Solution
I wrote a VS2005 VB.Net Asp.Net Solution to demonstrate the use of cWhichBrowser. Click here to run the demo.
Sample Calling Code
Dim o As New cWhichBrowser
If o.IsIE9 Then
'Do IE9 Stuff
ElseIf o.IsFireFox Then
'Do Firefox Stuff
ElseIf o.IsIPad Then
'Do IPad Stuff
Request.Browser returns information about the client's browser, for example:
Dim sBrowserType As String = .Type
Dim sBrowserName As String = .Browser
Download VB.Net Code
Previous Tip Tip Index Next Tip