<!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>
<title>无标题页</title>
<script type="text/javascript">
var Cookie = {
setCookie:function(name,value,option){
var str = name + "=" + escape(value);
if(option){
if(option.expireDays){
var date = new Date();
var ms = option.expireDays * 24 * 3600 * 1000;
date.setTime(date.getTime() + ms);
str += "; expires=" + date.toGMTString();
}
if(option.path)str += ";path=" + option.path;
if(option.domain)str += ";domain=" + option.domain;
if(option.secure)str += ";true";
}
document.cookie = str;
},
getCookie:function(name){
var cookies = document.cookie.split(";");
for(var i=0; i<cookies.length;i++){
var arr=cookies[i].split("=");
if(arr[0]==name){
return unescape(arr[1]);
}
}
return "";
},
delCookie:function(name){
this.setCookie(name,"",{expireDays:-1});
}
}
window.οnlοad=function(){
if("1"==Cookie.getCookie("diffmaker")){
alert("找到Cookie,我将不再刷新页面,并删除Cookie");
Cookie.delCookie("diffmaker");
}else{
alert("没有找到Cookie,我将刷新页面!");
Cookie.setCookie("diffmaker","1",null);
window.location.reload(true);
}
}
</script>
</head>
<body>
</body>
</html>
JSP获取上一个访问页面URL的方法:通过request.getHeader("Referer")就可以获得上一访问页面的url地址。