[英]Redirect to home page after submitting contact form and saying thank you
在提交联系表格并转到“谢谢”页面之后,我试图使我的网站重定向到主页。 除了重定向“谢谢后”页面外,它运行良好,如果我删除“谢谢”页面,它也可以正常工作。 我知道我需要在该行之后添加一个of语句,然后在header(www.google.com)类型的东西上,但是不确定if语句要放置什么。
如果有人可以让我走上正确的轨道,那么我将联系表单文件上传到下面的Dropbox链接中。 提前致谢。
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-HTML重定向:
<!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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.