Showing posts with label Check Browser Supports. Show all posts
Showing posts with label Check Browser Supports. Show all posts

To Verifies that the browser supports the required capabilities of JavaScript

Verifies that the browser supports the required capabilities of JavaScript.
The following code returns "True" else "False" If Browserversion and Javscript enabled .

Code :
    Public Function fnDetectBrowserCapabilities() As Boolean
       Try
           Dim strBrowser As String = String.Empty
           Dim intVersion As Int16 = 0
           Dim boolFrames As Boolean = False
           Dim boolTables As Boolean = False
           Dim boolCookies As Boolean = False
           Dim boolActiveX As Boolean = False
           Dim decJavaScript As Decimal = 0.0

           strBrowser = HttpContext.Current.Request.Browser.Browser
           intVersion = HttpContext.Current.Request.Browser.MajorVersion
           boolFrames = HttpContext.Current.Request.Browser.Frames
           boolTables = HttpContext.Current.Request.Browser.Tables
           boolCookies = HttpContext.Current.Request.Browser.Cookies
           decJavaScript = CDec(HttpContext.Current.Request.Browser.EcmaScriptVersion.ToString)
           boolActiveX = HttpContext.Current.Request.Browser.ActiveXControls

           If strBrowser = "IE" AndAlso intVersion < 6 Then
               Return False
           ElseIf strBrowser = "Firefox" AndAlso intVersion < 2 Then
               Return False
           ElseIf boolFrames = False Then
               Return False
           ElseIf boolTables = False Then
               Return False
           ElseIf boolCookies = False Then
               Return False
           ElseIf decJavaScript < 1 Then
               Return False
           ElseIf strBrowser = "IE" AndAlso boolActiveX = False Then
               Return False
           Else
               Return True
           End If

       Catch ex As Exception
           Return False
       End Try

   End Function