Forum Moderators: open

Message Too Old, No Replies

How to Add Simple Cookie to PopUp Javascript?

Per session or one-time cookie into already made script here...

         

damlag

9:28 am on Jul 5, 2006 (gmt 0)

10+ Year Member



Hello guys,

I have a javascript here. It's a sliding popup script. But problem is that there's no cookie here, so even if I reload a page 10 times, visitors will see a popup 10 times.

I don't want to annoy them

Could you help me to add a per session cookie here?

<SCRIPT language=JavaScript type=text/javascript>
<!--
document.write("<table width='460' height='400' border='0' cellpadding='0' cellspacing='0' style='display:none;position:absolute;top:10px;left:10px;empty-cells:hide' id='slidein'>");
document.write("<tr><td colspan='3'><img src='img/dropin460top.gif' width='460' height='90'></td></tr>");
document.write("<tr><td background='drop.gif' width='15' height='295'><img src='im.gif' width='15' height='1'></td>");
document.write("<td bgcolor='white' width='430'>");
document.write("<table width='430 height='100%' border='0' cellpadding='0' cellspacing='0'><tr>");
document.write("<td height='12' valign='top' bgcolor='white' style='cursor:hand'> ");
document.write("<div align='right' onclick='javascript:closewin();'><img src='close.gif'>&nbsp;</div></td></tr>");
document.write("<tr><td width='100%' colspan='2' valign='top' bgcolor='white' id='dragtext' style='padding:4px' align=center>");
document.write("<span class='class1'>Hello</span>");

if ( document.getElementById ) newlayer = document.getElementById ( "slidein" );
else newlayer = document.all ["slidein"];

function placewin ( ) {

if ( document.getElementById ) content = document.getElementById ( "elemid" );
else content = document.all ["elemid"];
if ( content.style.display == "none" ) { content.style.display = ""; newlayer.style.height = "170px"; }
else { content.style.display = "none"; newlayer.style.height = "30px"; } }

function closewin ( ) { newlayer.style.display = "none"; }
var wdt = 10, hgt = 20;
function xoff ( ) { return ( ( window.pageXOffset )? window.pageXOffset : document.body.scrollLeft ) + wdt; }
function yoff ( ) { return ( ( window.pageYOffset )? window.pageYOffset : document.body.scrollTop ) + hgt; }
function autoclose ( ) { newlayer.style.top = yoff ( ); newlayer.style.left = xoff ( ); setTimeout ( "autoclose ( );", 1000 ); }
function pwID43568534v144 ( ) {
if ( wdt!= 150 ¦¦ hgt!= 20 ) {
if ( wdt!= 150 )
if ( Math.abs ( wdt - 150 ) <= 16.000000 ) wdt = 150;
else
if ( wdt < 150 ) wdt += 16.000000;
else wdt -= 16.000000;
if ( hgt!= 20 )
if ( Math.abs ( hgt - 20 ) <= 16.000000 ) hgt = 20;
else
if ( hgt < 20 ) hgt += 16.000000;
else hgt -= 16.000000; newlayer.style.top = yoff ( ); newlayer.style.left = xoff ( ); setTimeout ( "pwID43568534v144();", 20 ); }
else autoclose ( ); }
function timedclose ( ) { wdt = 150; hgt = 20; switch ( 1 ) { case 3: wdt = -187; break; case 4: wdt = ( ( window.innerWidth )? window.innerWidth : document.body.clientWidth ); break; case 1: hgt = -225; break; case 2: hgt = ( ( window.innerHeight )? window.innerHeight : document.body.clientHeight); break; } newlayer.style.top = yoff ( ); newlayer.style.left = xoff ( ); newlayer.style.display = ""; pwID43568534v144 ( ); } setTimeout ( "timedclose ( );", 7000 );
var pwID43568534v157, pwID43568534v158;
function pwID43568534v159 ( e ) { v160 = ( document.all )? event.clientX : e.clientX; v161 = ( document.all )? event.clientY : e.clientY; wdt += v160 - pwID43568534v157; hgt += v161 - pwID43568534v158; pwID43568534v157 = v160; pwID43568534v158 = v161; newlayer.style.top = yoff ( ); newlayer.style.left = xoff ( ); }
function pwID43568534v162 ( ) { }
function pwID43568534v163 ( ) { document.onmousemove = pwID43568534v162; document.onmouseup = pwID43568534v162; }
function pwID43568534v164 ( v165 ) { pwID43568534v157 = ( document.all )? event.clientX : v165.clientX; pwID43568534v158 = ( document.all )? event.clientY : v165.clientY; document.onmousemove = pwID43568534v159; document.onmouseup = pwID43568534v163; } newlayer.onmousedown = pwID43568534v164;
//-->
</SCRIPT>

I couldn't find help anywhere else... I'd appreciate if you could help me out here.

adni18

2:09 pm on Jul 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure there's such thing as a per-session cookie. Only for an amount of time.

damlag

11:41 pm on Jul 7, 2006 (gmt 0)

10+ Year Member



Well, yes. For the amount of time.. Any kind of time would be good. 2 days or 60 days or whatever...

There are various cookie scripts, but I don't know how to attach those cookie names and values to this script...

If someone could help me out, it would be great...

adni18

1:49 pm on Jul 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two seconds in googling yields:

[webreference.com...]

damlag

6:17 am on Jul 14, 2006 (gmt 0)

10+ Year Member



Thank You very much for that... I've found some others, but they don't seem to be working...

Is it enough, just to paste this script? Or I have to attach that to the popup somehow?

Thanx.

adni18

3:12 am on Jul 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just read the cookie and if the value is "YES" or undefined (null), then set the cookie to be "YES" and expire in 24 hours or something, then display the popup.

Otherwise, delete the cookie.