Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用html或javascript重定向_Javascript_Html_Redirect - Fatal编程技术网

使用html或javascript重定向

使用html或javascript重定向,javascript,html,redirect,Javascript,Html,Redirect,我在一个页面上工作,我需要将人们从我的主页重定向到我的封面。虽然之后仍然可以返回主页(学校项目的一部分),但我有返回index.html的链接,但不确定重定向的最佳实践是什么 我正在使用代码: <head> <meta charset="utf-8"> <meta http-equiv="refresh" content="1; url=http://www.cameronwebsites.com/wps/cover.html/" /> <title&g

我在一个页面上工作,我需要将人们从我的主页重定向到我的封面。虽然之后仍然可以返回主页(学校项目的一部分),但我有返回index.html的链接,但不确定重定向的最佳实践是什么

我正在使用代码:

<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="1; url=http://www.cameronwebsites.com/wps/cover.html/" />
<title>Brillings Fittings Inc - Home</title>
<link href="css/styles.css" rel="stylesheet" type="text/css">
        <script type="text/javascript">
            window.location.href = "http://www.cameronwebsites.com/wps/cover.html"
        </script>
</head> 

布里林斯配件公司-主页
window.location.href=”http://www.cameronwebsites.com/wps/cover.html"

但是它一直把我重定向到examples.com而不是实际的URL?我很困惑。

如果这是您的实际代码,那么您缺少引号

url应该是
url=”http://www.cameronwebsites.com/wps/cover.html/“


meta refresh标签是重定向的最简单方式,因此我想说您可以继续使用。

您可以在X秒后重定向,以便在转到另一页之前显示消息

<head>
    <meta charset="utf-8">
    <title>Brillings Fittings Inc - Home</title>
    <link href="css/styles.css" rel="stylesheet" type="text/css">
    <script type="text/javascript">
        function redir(){
            window.location.href = "http://www.cameronwebsites.com/wps/cover.html"
        }
        setTimeout ("redir()", 1000); //1 second
    </script>
</head>

布里林斯配件公司-主页
函数redir(){
window.location.href=”http://www.cameronwebsites.com/wps/cover.html"
}
setTimeout(“redir()”,1000)//1秒

清除浏览器的缓存,这可能是问题所在。Ctrl+F5应该可以完成这项工作—您可能不需要javascript和元重定向。使用一个或另一个你应该使用JavaScript重定向,因为W3C不鼓励使用元刷新。@Script47你从哪里得到这个?@MaximZhukov虽然是很久以前的事了,但基于我记得在哪里读到的这篇文章的参考线索进行快速搜索。
url周围应该有单引号。我很高兴能帮助@JasonCameron