Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS cookie problems

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #34761
    Brightonmike
    Member

    Hey guys, any help with this? Here’s the HTML:

       



    This website is Beta. This means we're still testing it to make sure it's working. If you have any problems our old site is still live here.


    If you close this box it will not appear again.



    Here’s the script:

    function closeBox(toClose) {
    document.getElementById(toClose).style.display = "none";
    setCookie(toClose, "closed", 365);
    }
    function setCookie(cName, value, expiredays) {
    var expDate = new Date();
    expDate.setDate(expDate.getDate()+expiredays);
    document.cookie=cName + "=" + escape(value) +
    ";expires=" + expDate.toGMTString();
    }
    function loadMsg(msgClass) {
    msg = document.getElementsByTagName("div");
    for (i=0; i if(msg.className == msgClass) {
    if(document.cookie.indexOf(msg
    .id) == -1) {
    msg
    .style.display = "block";
    }
    }
    }
    }

    This was working. But, for some reason, now it doesn’t. Any ideas?

    All I want, is the div to show on first visit, but not on recurring visits by the same user.

    #89026
    Mottie
    Member

    How are you calling the “loadMsg” function?

    Also, have you considered just switching over to using HTML5 local storage? It’s sooo much easier.

    #89027
    Brightonmike
    Member

    Just had a read. I have no idea how I’d write a script to do what I want using it though.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.