中英文切换

2019-03-13 23:33:57来源:博客园 阅读 ()

新老客户大回馈,云服务器低至5折

//首页
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();
})


原文链接:https://www.cnblogs.com/shamszhang/p/10524829.html
如有疑问请与原作者联系

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:整理数组去重的几种常用方法

下一篇:正则表达式入门-程序员必备