Beyond the Basics |
JavaScript Question | > |
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
OK - here's the deal: http://www.countlesshorizons.com/test when you go to this page, then leave, a window will pop up. It has a few options on it. In theory, what it's supposed to do is set a cookie so that when you tell it that you don't want to see it again, you won't. But for some reason, I have something messed up and it doesn't write the cookie...? Any help here would be appreciated. Thanks, <!-- // /*Cookie Controlled Pop Window - modified by Brad Richardson at speculativevision.com from original cookie script by echoecho.com*/ /* reads the cookie */ function getCookie(NameOfCookie){ if (document.cookie.length > 0) { begin = document.cookie.indexOf(NameOfCookie+"="); if (begin != -1) { begin += NameOfCookie.length+1; end = document.cookie.indexOf(";", begin); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(begin, end)); } } return null; } /* deletes the cookie if a link is provided to do so */ function delCookie (NameOfCookie) { if (getCookie(NameOfCookie)) { document.cookie = NameOfCookie + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; } } /* pops up the window if the cookie has not been set */ function DoTheCookieStuff() { visited=getCookie('visited'); if (visited==null) { MyWindow=window.open('http://www.countlesshorizons.com/poems/subscribe1.htm',"subscription","toolbar=0, location=0,directories=0,status=no,menubar=no,scrollbars=no,resizable=no,width=640,height=480,left = 192, top = 144") } } // --> |
||
© Copyright 2001 C.G. Ward - All Rights Reserved | |||
Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669Michigan, US |
You have a function to read the cookie, one to delete the cookie, and one to open the popup based on the content of the cookie. But, Chris, you have nothing in the script to set a cookie. Shouldn't the code to set the cookie be in subscribe1.htm any way? |
||
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
And it is. Sorry for the confusion. The above code is in the include, brought in by the "main" page. Here's what's on the subscribe1.htm: <!-- // /* Cookie Controlled Pop Window - modified by Brad Richardson at speculativevision.com from original cookie script by echoecho.com */ /* sets the cookie */ function setCookie(NameOfCookie, value, expiredays) { var ExpireDate = new Date (); ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000)); document.cookie = NameOfCookie + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()); } /* sets a default cookie in case the user closes the window */ /* without using the links. Change 30 to whatever you want it to be */ function SetDefault() { setCookie('visited','yes',30); } /* sets parameters for Remind Me link and closes pop up */ /* change 1 to set number of days for cookie to expire */ function SetRemindMe() { setCookie('visited','yes',1); self.close(); } /* sets parameters for Don't Remind Me link and closes pop up */ /* change 365 to set number of days for cookie to expire */ function SetDontRemindMe() { setCookie('visited','yes',365); self.close(); } //--> *sigh* LOL |
||
Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669Michigan, US |
Your code is doing exactly what you have asked it to do, Chris. Here's the cookie it gave me (and the clue to your problem) www.countlesshorizons.com FALSE /poems FALSE 1012707844 visited yes [This message has been edited by Ron (edited 02-02-2001).] |
||
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
And I still aren't smart enough to figure it out... here's what it gave me: visited yes www.countlesshorizons.com/poems/ 0 1940402816 29402379 2069334176 29396344 * And still no clue... I feel stupid, but I'm not seeing what's wrong. Chris PS: I do "get" to see the horizontal scroll bar with those non-resizable pop-ups... (ie: Review Topic...) |
||
Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669Michigan, US |
Okay, here's another clue. Move test.html into your /poems directory and run it from there... |
||
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
*banging head against desk* Thank you Ron. I haven't tried it, but I just heard a loud "click" in the room, and the radio's off. Chris |
||
DragonFang Senior Member
since 2000-03-09
Posts 522Missouri, USA |
ACK!! COOKIES EVIL!!!!!!! (I just say that becuase I've never understood how to use them... I really must get a book on javascript) "Sa souvraya niende missian ye." \ I am lost in my own mind. |
||
Nan
Administrator
Member Seraphic
since 1999-05-20
Posts 21191Cape Cod Massachusetts USA |
.... and I have to return an accidentally borrowed one... |
||
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
Ahhhhhhhhhhhhhhh! MUCH better. Thank you Ron. Such a simple answer to what was proving to be a large headache!!! Those interested in the results can visit http://www.countlesshorizons.com - The script will be activated when you leave the main page. Chris |
||
⇧ top of page ⇧ | > | |
All times are ET (US). All dates are in Year-Month-Day format. |