Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Using a lightweight server that does basic serving of pages and doesn't have a api call for browser detection (like in ASP.NET, for example).

What is the best way to go about finding what browser the user is using?

Just parse the request header or is there some other way?

EDIT
Server:
http://www.goahead.com/

share|improve this question
1  
What server are you using? –  Adam Prax May 5 '11 at 18:20
    
@Adam, see edit –  Tommy May 5 '11 at 18:28
add comment

2 Answers 2

If the user requests the page that is present on the server, then you can write your own Browser Detection Script. It can be in any language, Javascript, C# .Net, Or JSP etc.,

Here is the sample, that is in Javascript:

<script type="text/javascript">

txt = "<p>Browser CodeName: " + navigator.appCodeName + "</p>";
txt+= "<p>Browser Name: " + navigator.appName + "</p>";
txt+= "<p>Browser Version: " + navigator.appVersion + "</p>";
txt+= "<p>Cookies Enabled: " + navigator.cookieEnabled + "</p>";
txt+= "<p>Platform: " + navigator.platform + "</p>";
txt+= "<p>User-agent header: " + navigator.userAgent + "</p>";

document.getElementById("example").innerHTML=txt;

</script>

try pasting this in the html of the page. Then this will detect the browser. If you need any, do comment

share|improve this answer
    
what can I do on the server side with this? Do I parse it? Thank you. –  Tommy May 5 '11 at 18:33
    
This doesn't seem to be what the OP is looking for. He wants to determine the browser on the server-side, rather than on the client-side. Javascript is run inside the user's browser, not by the server. –  Adam Prax May 5 '11 at 18:56
    
On your server, you will be having HTML Pages right. Embed this code into the HTML Page. This will be detecting the Browser. So once you detect the browser, you can proceed. Your Que says, "What is the best way to go about finding what browser the user is using?" So here is the solution. You have find out the user browser. ! –  Mohan Gajula May 5 '11 at 18:56
    
@Adam Parx: To detect the browser of the client, client needs to request from the server initially, lets say, user requested the above javascript containing html page. Now as soon as the page is loaded, postback the page data to Server. Bingo, you have detected the user browser. –  Mohan Gajula May 5 '11 at 18:58
add comment

According to the information in the link you provided, your webserver supports classic ASP.

You can use ASP to grab and parse the user agent string to determine the client's browser.

<%
user_agent = request.servervariables("HTTP_USER_AGENT")
response.write(user_agent)
%>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.