PDA

View Full Version : Javascript floating layer needs cookie



fredmjf
08-07-2012, 06:54 PM
Hello,
Who knows how to make a cookie for the script below so the layer only once appears in 24 hours? If possible complete script because i'm not so good in scripting.


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nieuwe pagina 1</title>

</head>

<body>
<script language="JavaScript1.2">
<!--
isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isActive=false;

function MoveInit(e){
topOne=isIE ? "BODY" : "HTML";
whichOne=isIE ? document.all.FloatingLayer : document.getElementById("FloatingLayer");
ActiveOne=isIE ? event.srcElement : e.target;
while (ActiveOne.id!="titleBar"&&ActiveOne.tagName!=topOne){
ActiveOne=isIE ? ActiveOne.parentElement : ActiveOne.parentNode;
}
if (ActiveOne.id=="titleBar"){
offsetx=isIE ? event.clientX : e.clientX;
offsety=isIE ? event.clientY : e.clientY;
nowX=parseInt(whichOne.style.left);
nowY=parseInt(whichOne.style.top);
MoveEnabled=true;
document.onmousemove=Move;
}
}

function Move(e){
if (!MoveEnabled) return;
whichOne.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx;
whichOne.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
return false;
}

function MoveN4(whatOne){
if (!isN4) return;
N4=eval(whatOne);
N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
N4.onmousedown=function(e){
N4.captureEvents(Event.MOUSEMOVE);
N4x=e.x;
N4y=e.y;
}
N4.onmousemove=function(e){
if (isActive){
N4.moveBy(e.x-N4x,e.y-N4y);
return false;
}
}
N4.onmouseup=function(){
N4.releaseEvents(Event.MOUSEMOVE);
}
}

function ToggleFloatingLayer(DivID, iState) // 1 visible, 0 hidden
{
if(document.layers) //NN4+
{
document.layers[DivID].visibility = iState ? "show" : "hide";
}
else if(document.getElementById) //gecko(NN6) + IE 5+
{
var obj = document.getElementById(DivID);
obj.style.visibility = iState ? "visible" : "hidden";
}
else if(document.all) // IE 4
{
document.all[DivID].style.visibility = iState ? "visible" : "hidden";
}
}

document.onmousedown=MoveInit;
document.onmouseup=Function("MoveEnabled=false");
// -->
</script>



<!-- Start Floating Layer -->
<div id="FloatingLayer" style="position:absolute;width:600px;left:200;top:150;visibility:visible">
<table border="0" width="600" bgcolor="#000000" cellspacing="0" cellpadding="5">
<tr>
<td width="100%"> <table border="0" width="100%" cellspacing="0" cellpadding="0" height="36">
<tr>
<td id="titleBar" style="cursor:move" width="100%"> <ilayer width="100%" onSelectStart="return false">
<layer width="100%" onMouseover="isActive=true;if (isN4) MoveN4(FloatingLayer)" onMouseout="isActive=false">
<font face="Arial" color="#FFFFFF">HET NIEUWE AJAXFANZONE.NL I-MAGZINE IS WEER UIT!</font></layer>
</ilayer></td>
<td style="cursor:hand" valign="top"> <a href="#" onClick="ToggleFloatingLayer('FloatingLayer',0);return false"><font color="#ffffff" size="2" face="arial" style="text-decoration:none">X</font></a>
</td>
</tr>
<tr>
<td width="100%" bgcolor="#FFFFFF" style="padding:4px" colspan="2">
<!-- place your HTML content here-->
<a href="http://ajaxfanzone.hetclubmagazine.nl/" target="_blank"><img src="http://members.home.nl/ajaxf-side/fotos/2012/0806magazine_groot.jpg" border="0"></a>
<!-- End of content area -->
</td>
</tr>
</table></td>
</tr>
</table>
</div>
<!-- End Floating layer -->


</body>

</html>