3

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
5
  • Possible duplicate of: stackoverflow.com/questions/220149/… Commented 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-Language Commented Jun 8, 2018 at 18:37
  • stackoverflow.com/questions/1043339/… ? Commented 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. Commented Jun 8, 2018 at 23:45
  • Possible duplicate of Best way to determine user's locale within browser Commented Jun 8, 2018 at 23:53

1 Answer 1

4

The main language :

navigator.language

All languages :

navigator.languages
answered Jun 8, 2018 at 19:13
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.