Results 1 to 2 of 2

Thread: JavaScript window and cookies...

Hybrid View

  1. #1
    Join Date
    Apr 2007

    JavaScript window and cookies...

    My problem is this: I want to pop open a window when a user visits my site but only if that window isn't already opened. This presents a problem obviously with the user changing pages. I can set a variable in JavaScript but of course once I navigate away, that variable is non-existent again. I need this because the window plays some music, but right now it pops that window up for every page load, even if the window is open, thereby refreshing it and repeating the songs which I want to keep playing, not restart.

    I was looking into using cookies to do this but I want to know if it's possible and this seems like the best place to ask. My idea is, upon page load of any page on my site, check to see if a cookie is set, a name of my choosing. If so, then I would pop open my window. If it is set, I'd not run the function to pop open the window. I would also want the cookie to have a time set on it, like let's say 10 minutes, so that if the user wants to come back to the site, it would still pop that window up, if they haven't cleared their cookies yet.

    Even further, if the user closes the player window, or their entire browser, is there a way to clear the cookie then or do I just have to use expiry to do this?

    Is this feasible, and if so, is it a lot of work? Thanks!

  2. #2
    Join Date
    Apr 2007
    It seems that I've solved most of my problem just now, with the help of this page.http://www.quirksmode.org/js/cookies.html

    I'm still trying to figure out if I can erase the cookie upon the closing of the entire browser, but that may be annoying if the user doesn't want the player to stay open after they've closed it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center