中英文切换
//首页
var zh_index = {
"index1":"首页",
"index2":"产品实例"
};
var en_index = {
"index1":"index",
"index2":"product examples"
};
//服务支持
var zh_servicesupport = {
"servicesupport1":"首页",
"servicesupport2":"产品实例"
};
var en_servicesupport = {
"servicesupport1":"index",
"servicesupport2":"product examples"
};
var zh = {"index":zh_index,"servicesupport":zh_servicesupport};
var en = {"index":en_index,"servicesupport":en_servicesupport};
var language = [zh,en];
$(function(){
var value = sessionstorage.getitem("language");
var pathname = window.location.pathname;
var index = pathname.lastindexof("\/");
pathname = pathname.substring(index + 1, pathname.length).split(".html")[0];
if(value==null || value==0){
value=0;
}
var data = language[value][pathname];
for (var i = 1; i <= 2; i++) {
$("#"+pathname+i).text(data[pathname+i])
}
});
$("#change").click(function() {
var value = sessionstorage.getitem("language");
if(value==="1"){
sessionstorage.setitem("language", "0");
}else{
sessionstorage.setitem("language", "1");
}
window.location.reload();
})
上一篇: React创建组件的三种方式及其区别