Grow your CSS skills. Land your dream job.

Javascript pop-up and Cookie not working in Google Chrome

  • # April 6, 2013 at 6:22 pm

    Here’s the pen: http://codepen.io/TannerCampbell/pen/jwIHn

    Alert box should pop up informing the user that tickets are sold out but should happen only once. The JS is working in Opera, FF, IE, and Safari but not in Chrome. I copy/pasted this script from a site online as I am not that familiar with cookies; did I mess something up? If yes, what? If no, does anyone have a better solution?

    Thanks,
    Tanner

    # April 6, 2013 at 6:25 pm

    Huh, is this relevant?

    var page = “only-popup-once.html”;

    This came with the script, that page doesn’t actually exist. Should I remove it, or maybe change the value?

    # April 6, 2013 at 6:59 pm

    In the script you have on codepen, you aren’t using the vars `page` and `windowprops` so you can leave them as they are or remove them.

    Anyway, it works for me, got the pop up once and the count increments every refresh. If you `alert(count);` right after

    function checkCount() {
    var count = GetCookie(‘count’);

    you can test that for yourself (but remove the non JS junk from top and bottom). It works for me on Chrome 26 by the way.

    # April 6, 2013 at 7:21 pm

    Thanks, C-money.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".