Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 获取当前ajax url,并以不同的语言动态创建指向相应页面的链接_Php_Ajax_Header - Fatal编程技术网

Php 获取当前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 等等

我正在开发一个使用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

等等

该站点将以多种语言存在,我想将语言菜单放在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);
});