有些客户不喜欢系统自带的下拉框样式,于是自己用JS写一个。
在页首的php文件中(譬如/includes/templates/marcus/common/tpl_header_v1.php)增加对应的JS功能,然后再增加两个对应的图片按钮,示范如下:
function chgLan(obj){
var cUrl = window.location.href;
if (cUrl.includes("?language=en") || cUrl.includes("?language=cn")) {
cUrl = window.location.pathname + window.location.hash;
}
if(obj==1){
cUrl += "?language=en";
}else if(obj==2){
cUrl += "?language=cn";
}
window.location.href = cUrl;
}
<a href="javascript:chgLan(1)"><img src="/includes/languages/english/images/icon.gif"> EN</a>
<a href="javascript:chgLan(2)"><img src="/includes/languages/schinese/images/icon.gif"> 中文</a>
Comments | NOTHING