7 月 142011
 

原文(source): ASP、PHP 網頁控制備忘 « Jamyy's Weblog

於 ASP、PHP 網頁達到以下目的

1. 禁止返回上頁
2. 避免因 "重新整理網頁" (Reload Page) 造成資料重送

ASP (VBScript)

<%@LANGUAGE="VBSCRIPT" CODEPAGE="950"%>






<%
strAction = Request.Form("action")
if Session("action") > "" and Session("action") = strAction then
	Response.Write "Don't Do Refresh!"
else
	if strAction > "" then
		Response.Write "action= " & strAction
		Session("action") = strAction
	end if
end if
%>
" method="post">

ASP (JavaScript)

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="950"%>






<%
//Ref: http://support.microsoft.com/kb/296169
strAction = Request.Form("action").Item;
if (Session("action") > "" && Session("action") == strAction) {
	Response.Write("Don't Do Refresh!");
} else {
	if (strAction > "") {
		Response.Write("action= " + strAction);
		Session("action") = strAction;
	}
}
%>
" method="post">

PHP








 "" && $_SESSION['action'] == $strAction) {
	echo "Don't Do Refresh!";
} else {
	if ($strAction > "") {
		echo "action= " . $strAction;
		$_SESSION['action'] = $strAction;
	}
}
?>

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

CAPTCHA Image
Play CAPTCHA Audio
Reload Image