0

Possible Duplicate:
How to detect Safari, Chrome, IE, Firefox and Opera browser?

i am looking for a script to detect each browser and redirect to a specific page for each one, for example chrome users go to www.website.com/chrome, users to another one and mozilla user to another one.

Any one knows a script like this ?

Thanks

Community
  • 1
  • 1
  • 1
    java tag...? What are you looking for? A user script? What have you tried? – Rob W May 01 '12 at 08:18
  • 3
    You really shouldn't do this. Please write standard-conforming HTML and use CSS hacks for IE if necessary. – ThiefMaster May 01 '12 at 08:22
  • 3
    @ThiefMaster: Jumping to conclusions I think, what if the website is a help forum on how to use your current browser, as an example ;) – musefan May 01 '12 at 08:24

1 Answers1

1

Just detect the browsers in your prefered language by get the HTTP_USER_AGENT.

Here are some sample agents.

Response.Write Request.ServerVariables("HTTP_USER_AGENT")

' Desktops
' ******************************************

' Firefox 4 MAC OS
' Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

' Safari, MAC OS
' Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; de-de) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1

' Chrome, MAC OS
' Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30

' Chrome, Windows 2008
' Mozilla/5.0 (Windows NT 6.0) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.91 Safari/534.30

' IE 9, Windows 2008
' Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; .NET CLR 3.0.30729)

' Mobile
' ******************************************

' iPhone 4
' Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; de-de) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5

' Blackberry from OS v6
' Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en-US) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.141 Mobile Safari/534.1+

' Tablets:
' ******************************************

' Samsung Galaxa Tab Android
' Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

' Motorola Xoom Android
' Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13

' iPad
' Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

' iPad2
' Mozilla/5.0(iPad; U; CPU OS 4_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F191 Safari/6533.18.5

You can get some unique keywords of the agent and redirect. As you didn't say which language just copy the strings and modify a select case code block, this should work for you.

YvesR
  • 5,922
  • 6
  • 43
  • 70
  • Good info, but an answer should really include how to actually make use of this – musefan May 01 '12 at 08:27
  • He didn't said what language. There is also a link to some js solutions, but if he wants to redirect server sided he just need to read the user agent and the redirect in case of the result, isn't a big deal in php, asp, asp.net, ff. – YvesR May 01 '12 at 08:30
  • upvote and/or mark as answer then, that is the best way to say thank you :) – YvesR May 07 '12 at 10:03