1

我试图让我的网站在提交联系表格后重定向到主页,然后转到感谢页面。我让它运行良好,除了在感谢页面之后重定向之外,如果我删除感谢页面,它也适用。我知道我需要在该行之后添加一个 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>
4

3 回答 3

2

因为我在手机上所以不看页面,把这个放在感谢页面

<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>
于 2013-10-25T03:42:31.657 回答
0

您可以通过 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>
于 2013-10-25T04:35:20.653 回答
0

尝试这样的事情,以防用户确实禁用了javascript:

<?php

header( "Refresh: 5 url=http://yourdomain.com/" );

?>
<!DOCTYPE html>
<html>

<!-- HTML CODE GOES HERE -->

</html>

header()函数中的数字 5是页面重定向用户 url 之前的秒数。该header函数必须出现在任何 html 和/或 php 输出之前

于 2013-10-25T04:06:10.423 回答