/js获取浏览器语言(ie、ff、chrome)
- var language_en_us = "en-us";
- var language_zh_cn = "zh-cn";
- var currentLang;
- var en_lang = { 'test.name': "name",'test.age': "age"};
- var zh_lang = { 'test.name'': "名字",'test.age'': "年龄"};
- var current_lang_map;
- currentLang = navigator.language;
- if(!currentLang)
- currentLang = navigator.browserLanguage;
- if(currentLang.toLowerCase() == language_zh_CN)
- {
- current_lang_map = zh_lang;
- }
- else
- {
- current_lang_map = en_lang;
- }
- dirstr += "<div id=age' class='age'>" +current_lang_map['test.name']+":8"+"</div>";
js获取上下文路径(contextPath)
- //获取contextpath
- function getContextPath() {
- var pathName = document.location.pathname;
- var index = pathName.substr(1).indexOf("/");
- var result = pathName.substr(0,index+1);
- return result;
- }