我试图让我的网站在提交联系表格后重定向到主页,然后转到感谢页面。我运行良好,除了重定向"谢谢"页面后,如果我删除感谢页面,它也适用于。我知道我需要在该行之后加上一个 of 语句,然后是 header(www.google.com) 类型的东西,但不确定为 if 语句放什么。
我将联系表单文件上传到下面的保管箱链接中,如果有人能让我走上正确的轨道,那就太棒了。提前谢谢。
https://www.dropbox.com/sh/2zrci8b04989u3d/gEc3u6rPK4
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Thank you!</title>
<link rel="STYLESHEET" type="text/css" href="contact.css">
</head>
<body>
<script>
window.onload=function() {
setTimeout(function() {
location.replace("index.php");
},3000); // wait 3 seconds
}
</script>
<h2>Thank you...</h2>
<a href="index.php">click here if you are not redirected in a few seconds</a>
</body>
</html>
因为我在手机上,所以不用看页面,把它放在谢谢页面
<script>
window.onload=function() {
setTimeout(function() {
location.replace("somepage.php");
},3000); // wait 3 seconds
}
</script>
<h2>Thank you...</h2>
<a href="somepage.php">click here if you are not redirected in a few seconds</a>
尝试这样的事情,以防用户确实禁用了javascript:
<?php
header( "Refresh: 5 url=http://yourdomain.com/" );
?>
<!DOCTYPE html>
<html>
<!-- HTML CODE GOES HERE -->
</html>
header()
函数中的数字 5 是页面将用户重定向到 url 之前的秒数。header
函数必须位于任何 html 和/或 php 输出之前
您可以通过 3 种方式执行此操作。
1 - 网页重定向:
<!doctype html>
<head>
<META http-equiv="refresh" content="0;URL=http://www.example.com">
</head><body></body></html>
2 - PHP 标头重定向:
<?php
header('Location: http://www.example.com');
?>
<!doctype html><html><head></head><body></body></html>
3 - Javascript 重定向:
<!doctype html><html><head>
<script>
window.location.assign("http://www.example.com");
</script>
</head><body></body></html>