Identifying the version of a browser using JavaScript is quite straight forward.
Is there any way to identify the browser version without using JavaScript libraries??
I just felt that there should be some way to identify the browser version without using any external libraries. I'm just very much curious to know if there is any way to do so..
-
4Is there a reason you need to know what version of a browser someone is using?zzzzBov– zzzzBov2011年11月14日 16:19:03 +00:00Commented Nov 14, 2011 at 16:19
-
You'll need to be more specific with what you would like to do with this. There are ways of targeting CSS at certain browsers.James Montagne– James Montagne2011年11月14日 16:19:17 +00:00Commented Nov 14, 2011 at 16:19
-
1This question makes no sense to me. What would you do with a browser version without javascript. Acting on a browser version (to do something based on which browser version is way) requires logic which requires a programming language of some kind. IE has conditional comments. Is that what you want?jfriend00– jfriend002011年11月14日 16:20:08 +00:00Commented Nov 14, 2011 at 16:20
-
What is the purpose of identifying the browser, styling?Christofer Eliasson– Christofer Eliasson2011年11月14日 16:20:11 +00:00Commented Nov 14, 2011 at 16:20
-
2It's "JavaScript", not "Java script", "javascript", or "java script", all of which you had in your question. (I think that's a record, literally every place you mentioned it you wrote it slightly differently...) :-)T.J. Crowder– T.J. Crowder2011年11月14日 16:21:15 +00:00Commented Nov 14, 2011 at 16:21
5 Answers 5
If you're wanting to do this client-side, then you certainly can use javascript. However this is also trivial with most server-side languages. All you need is access to the User Agent HTTP header.
1 Comment
Most libraries just parse the user-agent string, which is sent to the server as an HTTP header, so any server side process could do it.
The usual warnings about browser sniffing being unreliable, hard to maintain, and usually the wrong solution to any given problem apply.
Comments
The http request contains the header User-Agent
Comments
You can include conditional comments in your HTML to select versions of IE, but as far as I know, it doesn't work for other browsers. http://www.positioniseverything.net/articles/cc-plus.html
Comments
Are you thinking of detection on the server side? For PHP there is this.