HTML网站上的网址重定向问题

时间:2020-09-07 07:42:58

标签: javascript html

我有一个html网站,想要将mbcv.com重定向到mbcv.com/index.html,因此,当任何人键入mbcv.com时,它将重定向到mbcv.com/index.html 我添加了js代码,但是在页面加载时正在加载,刷新无限时间并没有停止。 这些代码对我不起作用

 <meta http-equiv="refresh" content="0; URL="/index.html" />

 <script type="text/javascript>">
 window.location = "/index.html";
 </script>

4 个答案:

答案 0 :(得分:1)

也许可以帮助您:

<script type="text/javascript>">
   if (window.location.pathname === "/") {
       window.location = "/index.html";
    }
</script>

答案 1 :(得分:1)

function foo(arg1?: any, arg2?: any)

答案 2 :(得分:0)

尝试制作一个index.js文件,然后将其链接到html文件,因为问题可能出在您试图链接到与html网站相同的文件中的另一个网站。

答案 3 :(得分:0)

尝试一下 加载后会重定向

window.addEventListener('load', (event) => {window.location.replace("Your");});