I'd like use Javascript to find out my browser's default HTTP Accept-Language that it sends in an HTTP request. I'm aware that Javascript's XMLHTTPRequest Object has a getResponseHeader() method. Does it have a similar method for getting request headers? Or is there another way I can determine my browser's HTTP request header?
sideshowbarker
89.2k30 gold badges219 silver badges216 bronze badges
asked Jun 8, 2018 at 18:24
Brinley
7212 gold badges15 silver badges27 bronze badges
-
Possible duplicate of: stackoverflow.com/questions/220149/…Allen G– Allen G2018年06月08日 18:29:34 +00:00Commented Jun 8, 2018 at 18:29
-
It's not a duplicate. stackoverflow.com/questions/220149/… wanted to know User-Agent and Referrer. I'm want Accept-LanguageBrinley– Brinley2018年06月08日 18:37:20 +00:00Commented Jun 8, 2018 at 18:37
-
stackoverflow.com/questions/1043339/… ?user2226755– user22267552018年06月08日 19:11:30 +00:00Commented Jun 8, 2018 at 19:11
-
As far as the general question of getting access to request headers from your frontend JavaScript code, see the part of the answer at stackoverflow.com/a/220175/441757 which says, "Almost by definition, the client-side JavaScript is not at the receiving end of a http request, so it has no headers to read.". You can’t get access from your frontend code to headers that the browser itself sets after evaluating and executing your frontend code. In other words, your frontend code executes before the request headers are set.sideshowbarker– sideshowbarker2018年06月08日 23:45:27 +00:00Commented Jun 8, 2018 at 23:45
-
Possible duplicate of Best way to determine user's locale within browserHeretic Monkey– Heretic Monkey2018年06月08日 23:53:34 +00:00Commented Jun 8, 2018 at 23:53
1 Answer 1
The main language :
navigator.language
All languages :
navigator.languages
answered Jun 8, 2018 at 19:13
user2226755
13.3k6 gold badges55 silver badges77 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-js