cross-browser way of getting navigator.{browserLanguage, systemLanguage, userLanguage}
Is
var b = navigator.browserLanguage;
var sy = navigator.systemLanguage;
var u = navigator.userLanguage;
cross-browser and safe? Does JQuery have a better way of doing it?
One side question:- What is safe?
obj开发者_开发百科 == null
obj === null
-Ajay
None of those three work in Chrome, for example, but navigator.language
does. In my case it returns en-US
.
As to the second part of your question, both of those are "safe" in that they won't throw exceptions, but they don't have the same behavior: ==
will do type casting (i.e. 0 == ""
is true
), but ===
does not (i.e. 0 === ""
is false
). Generally ===
is less likely to introduce subtle bugs, so might be considered safer.
精彩评论