7

I'm going to detect user's keyboard language by javascript. I got a input (type of text) which should be filled with Persian characters. So, I need to alarm users change their keyboard language if their language is not Persian.

What I have found is this:

window.navigator.language;

which detects browser's language which is always En-us.

How could I solve that?

Super Hornet
  • 2,839
  • 5
  • 27
  • 55

1 Answers1

23

You can try like this:-

var language = window.navigator.userLanguage || window.navigator.language;
alert(language);

navigator.userLanguage works for IE

window.navigator.language works for firefox/opera/safari

Also check out this Thread

Community
  • 1
  • 1
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331