Php 获取当前ajax url,并以不同的语言动态创建指向相应页面的链接
我正在开发一个使用hashchange ajax导航的网站。URL如下所示:Php 获取当前ajax url,并以不同的语言动态创建指向相应页面的链接,php,ajax,header,Php,Ajax,Header,我正在开发一个使用hashchange ajax导航的网站。URL如下所示: $('a').each(function(){ // use some regexp to get and replace language code in $(this).attr('href') $(this).attr('href') = replace_langcode($(this).attr('href'), language); }); domain.com/#contact.html 等等
$('a').each(function(){
// use some regexp to get and replace language code in $(this).attr('href')
$(this).attr('href') = replace_langcode($(this).attr('href'), language);
});
domain.com/#contact.html
等等
该站点将以多种语言存在,我想将语言菜单放在ajax内容div之外,例如在标题中(页面的一部分保持不变)
我的问题是如何获取当前url并对其进行修改,以动态创建指向不同语言对应页面的链接
因此,如果当前页面是“domain.com/#contact.html”,我希望标题中的语言链接动态指向类似“domain.com/fr/#contact.html(法语)等内容
这是最好的方法吗
如果是的话,我该怎么做呢
谢谢你的帮助
干杯如何替换所有链接中的语言代码 使用jQuery,它将是这样的:
$('a').each(function(){
// use some regexp to get and replace language code in $(this).attr('href')
$(this).attr('href') = replace_langcode($(this).attr('href'), language);
});
替换所有链接中的语言代码怎么样 使用jQuery,它将是这样的:
$('a').each(function(){
// use some regexp to get and replace language code in $(this).attr('href')
$(this).attr('href') = replace_langcode($(this).attr('href'), language);
});