我需要让我的网站页面在加载时立即重定向到另一个页面。刷新HTML命令无效,因为它不会检查是否正在加载某个特定的URL。同时JavaScript也可以实现。
我需要让我的网站页面在加载时立即重定向到另一个页面。刷新HTML命令无效,因为它不会检查是否正在加载某个特定的URL。同时JavaScript也可以实现。
你可以使用 JavaScript 等待加载 事件,并使用以下其中之一:
window.onload = function() {
// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";
}
或者
window.onload = function() {
// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");
}
来源: 如何重定向到另一个网页?
只需在您的HTML的部分中添加一个meta
标签,像这样:
<html>
<head>
<meta http-equiv="refresh" content="0;url=http://redirect-to-this-page.com" />
<title></title>
</head>
<body></body>
</html>