【发布时间】:2021-10-22 19:42:22
【问题描述】:
【问题讨论】:
标签: javascript url
【问题讨论】:
标签: javascript url
只是为了给 Lazy Coder 的答案添加一点...
html:
<a href='bn' id='button'>Change Language to BN</a>
Javascript:
var button = document.body.getElementById('button'); // assuming there is a button with the id='button';
button.addEventListener('click', function(e){
e.preventDefault();//to stop link from processing.
var lang = button.href; // gets language from link
window.location = 'http://arshohag.com/'+lang+'/home';
}
【讨论】:
在你的 JS 点击事件中尝试这样的事情
window.location = 'http://arshohag.com/bn/home'
【讨论】:
你可以简单地用这一行来改变它:
window.location.pathname = "/bn/home";
【讨论】: