gpt4 book ai didi

javascript - 如何根据条件更改 URL

转载 作者:行者123 更新时间:2023-12-03 12:09:47 24 4
gpt4 key购买 nike

我需要根据我的 window.location 条件更改项目链接的 URL。我对 JAVA 不太熟悉,所以对此的任何帮助或指导将不胜感激。谢谢。

这是我迄今为止用来手动更改所述项目内容的代码(它是在单语 WP 主题上制作的双语网站的解决方法......)

<ul class="block-with-icons clearfix">
<li class="b1">
<a href="http://test.ca/?page_id=69">
<h5><script>
if(window.location.href== "http://testfrench.ca/?lang=fr"){
document.write("Bonjour")
} else {
document.write("Hello")
}
</script></h5>
<span> <script>
if(window.location.href== "http://testfrench.ca/?lang=fr"){
document.write("Informez-vous")
} else {
document.write("Get informed")
}
</script>
</span>
</a>
</li>

我现在需要的是在相同样式的 window.location 条件下路由到法语页面的链接,而不仅仅是英语页面。

最佳答案

尝试

尝试这个。我认为它工作正常

<li class="b1">

<script>
if(window.location.href== "http://testfrench.ca/?lang=fr"){
document.write("<a href=\"french page\">");
document.write("<h5>Bonjour</h5>");
document.write("<span>Informez-vous</span></a>")
} else {
document.write("<a href=\"http://test.ca/?page_id=69\">");
document.write("<h5>Hello</h5>");
document.write("<span>Get informed</span></a>")
}
</script>
</li>

关于javascript - 如何根据条件更改 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25008246/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com