Redirect from an HTML page
是否有可能设置一个基本的HTML
页面来重定向到加载的另一个页面?
Try using:
<meta http-equiv="refresh" content="0; url=http://example.com/" />
Note: Place it in the head section.
Additionally for older browsers if you add a quick link in case it doesn't refresh correctly:
<p><a href="http://example.com/">Redirect</a></p>
Will appear as
Redirect
This will still allow you to get to where you're going with an additional click.
I would use both meta, and JavaScript code and would have a link just in case.
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=http://example.com">
<script type="text/javascript">
window.location.href = "http://example.com"
</script>
<title>Page Redirection</title>
</head>
<body>
<!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
If you are not redirected automatically, follow this <a href='http://example.com'>link to example</a>.
</body>
</html>
For completeness, I think the best way, if possible, is to use server redirects, so send a 301 status code. This is easy to do via .htaccess
files using Apache, or via numerous plugins using WordPress. I am sure there are also plugins for all the major content management systems. Also, cPanel has very easy configuration for 301 redirects if you have that installed on your server.
JavaScript
<script language="javascript">
window.location.href = "http://example.com"
</script>
Meta tag
<meta http-equiv="refresh" content="0;url=http://example.com">
链接地址: http://www.djcxy.com/p/304.html
上一篇: 改变hr元素的颜色
下一篇: 从HTML页面重定向