javascript 客户端时区、语言的获取
时间:2010-08-26 来源:chenfery
<script type="text/javascript">
var d, tz, s = "";
d = new Date();
tz = d.getTimezoneOffset();
tz = tz*(-1);
if(tz < 0) {
s = s + 'GMT-';
tz = tz * (-1);
}
else s = s + 'GMT+';
if(tz >= 0) {
var hour = Math.floor(tz/60);
var minute = tz - Math.floor(tz/60) * 60;
if(hour < 10) s = s + "0" + hour;
else s = s + hour;
s = s + ':';
if(minute < 10) s = s + "0" + minute;
else s = s + minute;
alert(s);
alert('window.navigator.userLanguage:' + window.navigator.userLanguage);
alert('window.navigator.systemLanguage:' + window.navigator.systemLanguage);
alert('window.navigator.browserLanguage :' + window.navigator.browserLanguage );
var language = window.navigator.language;
alert('window.navigator.language:' + window.navigator.language);
if(!language){
language = window.navigator.browserLanguage;
alert('firefox window.navigator.browserLanguage:' + window.navigator.browserLanguage);
}
}
</script>