表单提交后,用js的goback后退后内容全没了。
找了N多文章,没找到原因。我加了个头,在firefox中可以后退了,在IE6、7、8中仍然不可以。
我加的header如下:
@header ( 'Cache-Control: store, no-cache, must-revalidate' );哪位能解决的,一百分全送。当前只给了十分,怕没人能解决,浪费了,解决了一定加分送上别告诉我什么在当前页面验证。绕过去的方法很多,我只想解决这个问题,不想绕过去!!!有兴趣的可以下载下面页面去试试。
我把页面内容也贴出来吧:
---------------------a.php------------------------------
<?php
session_start();
$_SESSION['aaa'] = "aaaaaaaaaaaa";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head><body>
<form id="form1" name="form1" method="post" action="b.php">
<input type="text" name="textfield" id="textfield" />
<input type="submit" name="button" id="button" value="Submit" />
</form>
</body>
</html>
---------------------b.php------------------------------
<?php session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
window.onload = function() {
alert("go back <?=$_SESSION['aaa']?>");
window.history.go(-1);
}
</script>
</head><body>
</body>
</html>
找了N多文章,没找到原因。我加了个头,在firefox中可以后退了,在IE6、7、8中仍然不可以。
我加的header如下:
@header ( 'Cache-Control: store, no-cache, must-revalidate' );哪位能解决的,一百分全送。当前只给了十分,怕没人能解决,浪费了,解决了一定加分送上别告诉我什么在当前页面验证。绕过去的方法很多,我只想解决这个问题,不想绕过去!!!有兴趣的可以下载下面页面去试试。
我把页面内容也贴出来吧:
---------------------a.php------------------------------
<?php
session_start();
$_SESSION['aaa'] = "aaaaaaaaaaaa";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head><body>
<form id="form1" name="form1" method="post" action="b.php">
<input type="text" name="textfield" id="textfield" />
<input type="submit" name="button" id="button" value="Submit" />
</form>
</body>
</html>
---------------------b.php------------------------------
<?php session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
window.onload = function() {
alert("go back <?=$_SESSION['aaa']?>");
window.history.go(-1);
}
</script>
</head><body>
</body>
</html>
是session_start()把header设置的内容冲了,怎么处理呢?session_start()输出的内容
---------- PHP ----------
Connection close
Date Fri, 18 Sep 2009 05:52:46 GMT
Server Microsoft-IIS/6.0
X-Powered-By ASP.NET, PHP/5.2.9-2
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma no-cache
Content-Type text/html
<form action="" method="post">
<input type="text" name="test" value="<?php echo $_POST['test']; ?>" />
<input type="submit" name="submit" />
</form>
怎么a.php就存session了?
================a.php==================
<?php
session_start();
$v = $_SESSION['aaa'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document </title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="b.php">
<input type="text" name="textfield" id="textfield" value='<?php echo $v;?>'/>
<input type="submit" name="button" id="button" value="Submit" />
</form>
</body>
</html> =======================b.php=====================
<?php
session_start();
if($_POST){
$_SESSION['aaa'] = $_POST['textfield'];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document </title>
<script type="text/javascript">
window.onload = function() {
alert("go back <?=$_SESSION['aaa']?>");
window.history.go(-1);
}
</script>
</head><body></body>
</html>
就不会把header给冲掉了。
go(-1)也没有能显示原来的内容了。
用你的代码测试通过
session_cache_limiter('private, must-revalidate');
showmsg() 后退里
里面不要用heaer()
要看情况使用的,会覆盖原始值的,估计楼主又得郁闷了