我需要我的一个网站页面在加载时立即重定向到另一个.刷新HTML命令不起作用,因为它不检查是否正在加载某个URL.此外,JavaScript也将工作.
Dav*_*hez 16
您可以使用JavaScript 等待加载事件,并使用以下任一项之一:
window.onload = function() {
// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";
}
Run Code Online (Sandbox Code Playgroud)
要么
window.onload = function() {
// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");
}
Run Code Online (Sandbox Code Playgroud)
来源:如何重定向到另一个网页?
只需meta在head您的部分中添加标签,HTML如下所示:
<html>
<head>
<meta http-equiv="refresh" content="0;url=http://redirect-to-this-page.com" />
<title></title>
</head>
<body></body>
</html>
Run Code Online (Sandbox Code Playgroud)