Cookie code from:
http://www.quirksmode.org/js/cookies.html
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
function doAlert(txt){
if(!readCookie('theAlert'))
alert(txt);
createCookie('theAlert',txt);
}
</script>
</head>
<body>
<span onmouseover="doAlert('Hello World');">Mouse Over Here</span>
</body>
</html>
Notes: Creates a session only cookie that allows the alert to fire once onmouseover of the item. Will fire every time if user has cookies disabled (unusual). Will fire again in the same session if user clears cookies (also unusual but, less so). A session only cookie lasts until all instances of the browser are closed. A persistent cookie can be set for (in the below case, 10) days:
Code:
createCookie('theAlert',txt,10)
Bookmarks