C and S Design.
Search Friendly Programming and Design



Get this Code: Click to download the ASP file.
Do not copy and paste the displayed code. The display function adds line breaks so what you see is definitely not what you would get.

Code for this Example. (Show A Disclaimer)

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML _ 
	4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" _ 
	content="text/html; charset=iso-8859-1">
<link rel="stylesheet" _ 
	href="style.css" type="text/css">
<style type="text/css">
#disclaimer {
	position:absolute;
	width:100%;
	height:100%;
	z-index:100;
	background-color:#333333;
}
#disclaimer #message {
	width:30%;
	height:300px;
	background-color: #FFFF00;
	margin:25% auto;
	border:3px blue outset;
	padding:5px;
	overflow:auto;
}
#disclaimer #formbox {
	margin:20px 0;
	text-align:center;
}
.hidden {
	visibility:hidden;
	display:none;
}
.visible {
	visibility:visible;
	display:block;
}
</style>

<script type="text/javascript">

	function setCookie(cName,cValue,cExpireDays) {
		var expDate=new Date();
		expDate.setDate(expDate.getDate()+cExpireDays);
		document.cookie=cName+ "=" +escape(cValue)+
		((cExpireDays==null) ? "" : _ 
	";expires="+expDate.toGMTString());
	}
	
	function getCookie(cName) {
		if (document.cookie.length>0)
		  {
		  cStart=document.cookie.indexOf(cName + "=");
		  if (cStart!=-1)
			{
			cStart=cStart + cName.length+1;
			cEnd=document.cookie.indexOf(";",cStart);
			if (cEnd==-1) cEnd=document.cookie.length;
			return unescape(document.cookie.substring(cStart,cEnd));
			}
		  }
		return "";
	}

	function getDisclaimElement() {
		return document.getElementById("disclaimer");
	}

	function getBodyHeight() {
		return document.body.clientHeight;
	}
		
	function check() {
	var disclaim = getDisclaimElement();
		var allow = getCookie("approved");
		if (allow == "") {
			disclaim.className = "visible"
			disclaim.style.height = getBodyHeight() + "px";
		} else {
			disclaim.className = "hidden";
		}
	}
	
	function respond(answer) {
	var disclaim = getDisclaimElement();
		if (!answer) {
			window.location = "notasniff.asp";
		} else {
			setCookie("approved","yes",1);
			disclaim.className = "hidden";
		}
	}
		
</script>
</head>

<body onload="check()">
<!-- this sections would have to be on every page or as _ 
	an include -->
<div id="disclaimer" _ 
	class="hidden">
<div id="message">
<h1> Disclaimer</h1>
Some stuff for the legal department to drool over.<br>
<br>
Click "I Agree" if you are Ok with this. Click _ 
	"Not a Sniff" if you aren't
<div id="formbox">
<form name="disclaim" action="" _ 
	method="">
<input type="button" name="ok" _ 
	value="I Agree" _ 
	onclick="respond(true)">
<input type="button" name="cancel" _ 
	value="Not a Sniff!" _ 
	onclick="respond(false)">
</form>
</div>
</div>
</div>
<!-- end -->
<a _ 
	 _ 
	href="javascript:setCookie('approved',",1);location.reload();">Clear Cookie and refresh the page</a><br>
<a href="default.asp">Back to start _ 
	page</a>
</body>
</html>



Valid HTML 4.01! Valid CSS! copyright © C and S Design 2004 - 2005
Website Design and SE Friendly Coding C and S Design