有谁知道如何在此脚本重定向并关闭窗口之前添加 5 秒的延迟?
<script>
window.opener.location = '/redirect.html';
window.close();
</script>
Run Code Online (Sandbox Code Playgroud)
使用setTimeout:
setTimeout(function() {
window.opener.location = '/redirect.html';
window.close();
}, 5000);
Run Code Online (Sandbox Code Playgroud)
它的工作原理是传入一个函数和一定的延迟(以毫秒为单位)。该函数将在延迟结束后被调用。
| 归档时间: |
|
| 查看次数: |
2124 次 |
| 最近记录: |