JavaScripting Help

They have: 5 posts

Joined: May 2000

Can someone please help...

Go to:

envy.nu/testing.html

I need to make that so that when you close the popup window it deletes the cookie. Currently if it sees the cookie you can either tell it to ignore it or accept it and not display if the cookie is there...Please help...

Thanks,
Taylor

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I'm not a javascript guru (by far), but try something like this:

// all of this goes in the popup window
<html>
&lt;script language=javascript&gt;
<!--
function deleteCookie() {
expireDate = new Date
expireDate.setDate(expireDate.getDate()-1)

<strong>cookieName</strong> = <strong>cookieName</strong> + "=;expires=" + expireDate.toGMTString()
}
//-->
&lt;/script&gt;
<body onUnLoad="deleteCookie()">
blah blah blah
</body>
</html>
'

I copied most of this out of a book, but I haven't tested it.
Good Luck,

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 5 posts

Joined: May 2000

I think that will work, seeing as I did not write this script in the first place and know very little about JS...Can you help me on the cookie name... it's on

http://www.envy.nu/testing7.html it's what you gave me.

Thanks,

Taylor

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

looks like it's "alreadypopped"

so the code would looks like this:

// all of this goes in the popup window
<html>
&lt;script language=javascript&gt;
<!--
function deleteCookie() {
expireDate = new Date
expireDate.setDate(expireDate.getDate()-1)

cookieName = "alreadypopped=;expires=" + expireDate.toGMTString()
}
//-->
&lt;/script&gt;
<body onUnLoad="deleteCookie()">
blah blah blah
</body>
</html>
'

Hope that works for ya.

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 5 posts

Joined: May 2000

THANKS!!!!!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.