any If statements to check browsers?

Discussion in 'C#' started by gilgalbiblewheel, Jul 31, 2007.

  1. #1
    Is there any If statement to check browsers?

    I want to check IE6, IE7 and Firefox.
     
    gilgalbiblewheel, Jul 31, 2007 IP
  2. dizzy

    dizzy Peon

    Messages:
    43
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Check the Request.ServerVariables("HTTP_USER_AGENT")

    For IE, the string will contain 'Mozilla'
    For Firefox, the string will contain 'Gecko' or 'Firefox'
     
    dizzy, Jul 31, 2007 IP
  3. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #3
    If its a non-server side issue, IE has things called conditional comments... which allow you to do X if IE 6 or IE55 or Less Than IE5 or whatever... Essentially it's comments to the rest of the world, but IE sees them as a psuedo programming block so you can define elements in IE to be Not Commented if certain criteria are met :)
     
    ccoonen, Aug 2, 2007 IP
  4. KowDot

    KowDot Peon

    Messages:
    296
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Something like
    [asp.net]
    If Request.Browser.Browser.ToLower.Contains("firefox") Then
    [javascript]
    if (navigator.userAgent.indexOf("Firefox")!=-1)
     
    KowDot, Aug 17, 2007 IP