根据浏览器语言更改URL

时间:2020-05-07 07:56:24

标签: javascript jquery

我有一个英文网站,并带有一个指向网站子域的URL https://subdomain.website.com按钮:

group by rollup

如何根据用户的浏览器语言向该URL添加类似with Tab_X (Col_1, Col_2, Col_3) as ( select 'A1', 'B1', 10 from dual union all select 'A1', 'B2', 7 from dual union all select 'A2', 'B1', 15 from dual union all select 'A2', 'B2', 6 from dual ) select Col_1 , null , case when grouping(Col_2) = 1 then sum(Col_3 * case when Col_2 = 'B1' then 1 else -1 end) else min(Col_3) end as Col_3 from Tab_X group by Col_1, rollup (Col_2) 之类的Google翻译附件,因此,如果默认情况下该用户的浏览器语言为法语,则URL将更改为<a href="https://subdomain.website.com" id="subdomainURL">Title</a> 。同样,如果用户使用另一种语言,则URL附加项将根据其浏览器默认语言而更改。

1 个答案:

答案 0 :(得分:2)

您可以像这样使用navigator.language

var lang = navigator.language.slice(0,2);
var el = document.getElementById('subdomainURL');
var href = `${el.href}#googtrans(en|${lang})`;
el.href = href;