Link to home
Start Free TrialLog in
Avatar of aplimedia
aplimediaFlag for Spain

asked on

Browser version detection.

Browser version detection.


Hi all,

I have a site which has sections for only the newer browsers. I am looking for some scripts or examples which could allow me to do the following.

If MyBropwser = IE 5.5 or later Then
Browser = Good
End If

If MyBropwser = FireFox 1.5 or later Then
Browser = Good
End If

If MyBropwser = Netscape 8 or later Then
Browser = Good
End If


If Browser = Good Then
Response.redirect(“GoHere.asp”)
Else
Response.redirect(“GoGetNewBrowser.asp”)
End If

Kind regards
Aplimedia

PS. No too interested in a Javascrip solution.
SOLUTION
Avatar of inviser
inviser

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aplimedia

ASKER

Hi inviser

I have tried your script, which detects IE correctly, however, getsno results at all for firefox, netscape, and thinks Opera8 is netscape 4...

Thanks anyway.

Kind regards

Aplimedia
httpUserAgent=Request.ServerVariables("HTTP_USER_AGENT")

if inStr(httpUserAgent, "MSIE 5") <> 0 then browser="MS IE 5"
if inStr(httpUserAgent, "MSIE 5.1") <> 0 then browser="MS IE 5.1"
if inStr(httpUserAgent, "MSIE 5.5") <> 0 then browser="MS IE 5.5"
if inStr(httpUserAgent, "MSIE 6") <> 0 then browser="MS IE 6"
if inStr(httpUserAgent, "/4.7") <> 0 then browser="NS 4.7x"
if inStr(httpUserAgent, "Netscape6") <> 0 then browser="NS 6"
if inStr(httpUserAgent, "Netscape/7") <> 0 then browser="NS 7"  
if inStr(httpUserAgent, "Opera 5") <> 0 then browser="OPERA 5"  
if inStr(httpUserAgent, "Opera 6") <> 0 then browser="OPERA 6"

Response.write browser
I have seen this script elswhere and althought it has a lot to offer, it has limitations. For example in a years time we will have IE 8.2 and Firefox2.5.09. These new version will not pass as their critieria are not listed in the browser checking script.

Thanks for your input.

Kind regards

Aplimedia
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
dfu23, Article is great, but that Solution is good for client side javaScript only.
Question is been asked in ASP TA, so we dont know whats the purpose of this Script.
>>But how about other browsers, obscure browsers?

I will only accept:

IE 5.5 or higher
FireFoxor
Netscape 8 or higher
Oper 8 or higher.


Everything else gets chucked out...

Aplimedia
And specifically said:

PS. No too interested in a Javascrip solution.


Aplimedia
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dfu23
dfu23

Then the question is why are you only allowing these "newer" browsers? What functionality needs to be supported by the visitors to your site?

The User Agent String can easily be spoofed ...
Avatar of sybe
> The User Agent String can easily be spoofed ...

Exactly. There are enough people browsing pretending to the google-spider, so they don't have to registrer in order to read articles.

Browser-detection is crap, you should make your code W3C-compliant, and then check the site with the most common browsers and eventually do some adaptations to correct for the errors in those browsers.

Also don't automatically exclude browsers. Just make a remark that the specific code has been checked for the browsers (and versions) you have checked it with, and that you can not guarantee that it works in other browsers.  But let people free to look at the pages with any browser. It might word you know, even if you did not check.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks to all.

aplimedia