This is the javascript (and HTML/CSS) to show a div the first time a user goes to a page but not the second time (or after a refresh or the user navigates away from the page).
I have used it to pop up a little un-obtrusive header that can be closed by clicking the cross.
The script is currently running on my martial arts clubs website.
<html>
<head>
<style type="text/css">
div.hidden {
display: none;
}
div.pophead {
padding: 10px 0pt;
text-align: center;
font-family: Arial,Helvetica,sans-serif;
font-size: 110%;
font-weight: bold;
background-color: #B7C134 !important;
border:2px solid black;
color: #111111;
display: block;
letter-spacing: 1px;
line-height: 1;
vertical-align: baseline;
}
</style>
<script type="text/javascript">
function checkcookie() {
popheaddiv=document.getElementById("pophead");
if (document.cookie.indexOf("mycookie")!=-1) {
popheaddiv.style.display="none";
}
else {
document.cookie="mycookie=1";
}
}
</script>
</head>
<body>
</div>
<div class="pophead" id="pophead">
New <a style="color: white !important; text-decoration:none" href="a link">Putney class</a> starts in the sports centre on the 1st of November! <a href="#" onclick="change('pophead', 'hidden');"><img src="/assets/2009/10/27/psd-delete-icon.png" width="16px" align="right" style="margin-right:80px;"></a> </div>
<script type="text/javascript">
<!--//check for the cookie and display div or set cookie
checkcookie();
-->
</script>
<p> Main Page Body to Go Here :) </p>
</body>
</html>
