ITeye博客

禁止页面缓存与离开页面确认

jil5 · 2012-11-29 20:17 · jsp · 编程语言 · Markdown

禁止页面缓存

 

response.addHeader("Cache-Control", "no-store, must-revalidate"); 
response.addHeader("Expires", "Thu, 01 Jan 1970 00:00:01 GMT");
response.setDateHeader ("Expires", 0); 
window.history.forward(1); 
location.replace("");

   

 

 

离开提示

 

var timeout=true;//设置变量 在某些时刻不提醒

//--------------离开提示---------------------	
	window.onbeforeunload = function(e){
		if(!timeout){
			window.event.returnValue='您确认离开考试页面吗?';
			 if (!window.event.reason) 
	            {
	              window.event.cancelBubble = true;
	            } 
	            else
	            {
	            	return;
	            }
			}
		}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。