http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/reference/behaviors/savehistory.asp See this webpage from microsoft msdn.
wasy(嘻嘻哈哈) :你说的第一个方法,还需要在head中加入:一个meta标签。完整的就是: -----------------------------------------------↓ <HTML> <HEAD> <!-- PERSISTENCE_NOTE: The meta tag is required for the saveHistory peer. --> <META name="save" content="history"><!-- PERSISTENCE_NOTE: The style block is required in Internet Explorer 5 Beta 1 for the saveHistory peer. --> <STYLE> .sHistory {behavior:url(#default#savehistory);} </STYLE> </HEAD> <BODY> <input type=text id="testHistorText" class=sHistory> <input type=text id="testNoHistorText"> </BODY> </HTML>
<script language=javascript>
history.go(-1);
</script>后退!!
main.html
-------------------------
<form action='b.php'>
<input>.....</form>b.php
-------------------------------------
<%php
......
if (不对,需要返回)
echo "<script language=javascript>history.go(-1)</script>";
结束
%>
try:
1.在head标记之间加上:
<style>
input{behavior:url(#default#savehistory);}
/*这里只是针对input控件,其他的也可以相应加上*/
</style>
<meta name="save" content="history">2.更改php.ini.
session.cache_limiter=private第一种方法不方便,第二种又会带来其他的毛病,你试一试就知道了继续寻找更简单方便的办法........
hehe,怎么跑到php版里面来了:)history.go(-1)对php是没有效果的,对asp,jsp等可以,hehe。
1、在提交页面用javascript验证,即在客户端验证
2、到php页面验证,当验证不准确时print "<script>alert('不正确');window.history.back();</script>或是楼上的history.go(-1);等都可以的。
function aa(){
if(document.form1.title.value==''){
alert('文章标题不能为空!');
return false;
}
if (document.form1.keyword.value==''){
alert('标题关键字不能为空!');
return false;
}
if(document.form1.text.value==''){
alert('文章正文不能为空!');
return false;
}
document.form1.target='_blank';
document.form1.action='asdfsdf.php';
document.form1.submit();
}
2、在php页面判断,不正确则退回,如:
print "<script>alert('不正确');window.history.back();</script>";
或是楼上的history.go(-1)都可以
你说的第二个方法,如果使用自己的或第三方的session系统到是比较有效。但遗憾的是我在做的项目使用的php自带的sesion。第一个方法确实有效,但需要对所有的input类型的表单设置。是有些麻烦。不过在没有找到好的方法之前,这个还是可行的。
thx lots of.
lanbor(兰波)
你说的使用javascript:history方法,这个早两年前都被证明对php是不起作用的。感谢以上朋友答复。
See this webpage from microsoft msdn.
-----------------------------------------------↓
<HTML>
<HEAD>
<!-- PERSISTENCE_NOTE: The meta tag is required for the saveHistory peer. -->
<META name="save" content="history"><!-- PERSISTENCE_NOTE: The style block is required in Internet Explorer 5 Beta 1 for the saveHistory peer. -->
<STYLE>
.sHistory {behavior:url(#default#savehistory);}
</STYLE>
</HEAD>
<BODY>
<input type=text id="testHistorText" class=sHistory>
<input type=text id="testNoHistorText">
</BODY>
</HTML>
hehe,怎么跑到php版里面来了:)
history.go(-1)对php是没有效果的,对asp,jsp等可以,hehe。
to lanbor(兰波)
你说的使用javascript:history方法,这个早两年前都被证明对php是不起作用的。 好像我根本不懂。在这里瞎说,骗分!!!我两年前就用php了,还做了一个大的商务网站:www.cpss.org.cn(一个人完成,包括所有的页面,所有的php程序)。虽然我现在改用asp,但我也不会这么菜呀。谁说history.go(-1)在php里没作用?
你们去看看 www.cpss.org.cn/test/a.php !!!!
我特意做的!!!!!!!!!
也不要什么<meta name="save" content="history">
也不要更改php.ini.
更不要什么session !!!!!!!!!!!
别那么激动。我的global页面中使用了以下http头。 ob_start();
@header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
@header("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT");
@header("Cache-Control: no-cache, must-revalidate");
@header("Pragma: no-cache"); 页面footer中使用了gzip压缩。
</body>
</html>
<?php if ($gzipoutput and !headers_sent() and function_exists("ob_start") and function_exists("crc32") and function_exists("gzcompress") and !$nozip) {
if (strpos(" ".$HTTP_ACCEPT_ENCODING,"x-gzip")) {
$encoding = "x-gzip";
}
if (strpos(" ".$HTTP_ACCEPT_ENCODING,"gzip")) {
$encoding = "gzip";
} if ($encoding) {
$text = ob_get_contents();
ob_end_clean(); header("Content-Encoding: $encoding"); $size = strlen($text);
$crc = crc32($text); $returntext = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
$returntext .= substr(gzcompress($text,$level),0,-4);
$returntext .= pack("V",$crc);
$returntext .= pack("V",$size); echo $returntext;
exit;
}
}
?>加上这些,你再试试你的方法还管用吗?
不要生气,我是实话是说,用history.go(-1)是不能解决这种情况的。
哈哈。只是刚才刚看都帖子有些不爽,换了你也会的。对不起,我太激动了。现在没事了。哈哈。www.cpss.org.cn/test/a.php。你看了吗?不是解决问题吗?
@header("Cache-Control: no-cache, must-revalidate");
@header("Pragma: no-cache");
返回以後也是空的。我的兩個系統的php都這樣!!!
但爲什麽兰波兄的卻又可以呢?奇怪了?
看來很有可能還是配置的問題????????等待更好的回答.....
我提供的代碼中好像有這個<meta>標簽吧.仔細看看
<input name=ljh type=text>
<input type=submit name=af value=send>
</FORM>
這個代碼有什麽問題嗎,進入test2後後退數據就空了,至少在我電腦上是這樣
------------------------------------------------
<?php
Header("Cache-Control: must-revalidate");
$offset = 60 * 60 * 24 * 1;
$ExpireString = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
Header($ExpireString);
?>
<html>
<head></head>
<body>
<form action="b.php">
<input name=text0><br><br>
<input name=text1>
<input type=submit value=submit>
</form>
</body>
</html>b.php
---------------------------------------------
<?
echo $text0;
echo $text1;
?><html>
<body>
<button onclick="history.go(-1)">返回</button>
</body>
</html>
你上面的代碼在我的電腦上面運行,後退數據還是空的:)
没事呀,
怎么没像你们说的那样复杂,还搞什么header
sytle
等,钻牛角?
,但这样的话,session_unregister()就不起作用了.所以在使用session_unregister()时,先使用语句:putenv("session.cache_limiter = nocache");(这样设置,只会在当前文件调用时的设定,别的程序或进程还是会使用原php.ini中的设置.)做以上处理好,问题基本解决,暂时还没有发现新的问题.(有待于进一步检验)!------------------
说一个之前wasy(嘻嘻哈哈)说的第一个方法,这个方法对html的页面有用,但对php的文件用处基本上是没有,在没有使用session_start()的页面中倒是有一些作用.
-------------------
感谢以上各位朋友的回复!
你完全可以用一个css文件控制整个web,局部的在用style控制。这样省事多了。
1.saveHistory
2.userData
php
3.设置缓存,不立即国旗
4.利用cookie或session