我想在特定时间后加载另一个HTML页面

I want to load another HTML page after a specific amount of time

本文关键字:加载 另一个 HTML 页面 定时间      更新时间:2023-09-26

我有一个html页面"form1.html",其中有一个动画图像。我想加载另一个页面"form2.html"后5秒。我该怎么做呢?

<script>
    setTimeout(function(){
        window.location.href = 'form2.html';
    }, 5000);
</script>

对于主页只添加'/'

<script>
    setTimeout(function(){
        window.location.href = '/';
    }, 5000);
</script>
<meta http-equiv="refresh" content="5;URL='form2.html'">

使用以下JavaScript代码:

<script>
    setTimeout(function(){
       window.location.href = 'form2.html';
    }, 5000);
</script>

使用Javascript的setTimeout:

<body onload="setTimeout(function(){window.location = 'form2.html';}, 5000)">