Web Analytics Made Easy -
StatCounter Setting Cookie to stop fancybox autoload - CodingForum

Announcement

Collapse
No announcement yet.

Setting Cookie to stop fancybox autoload

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • jQuery Setting Cookie to stop fancybox autoload

    Hi guys. I have a jQuery fancybox autoload which works great but what i want is once it opens (or is closed) to set a cookie that the user does not have to see it again for as long as they have that cookie!

    Again i understand that some users clear cookeies, some dont accept them, and thats their problem!

    What i need to do is make sure this function only happens once, ever....
    Code:
    script type="text/javascript">
        $(document).ready(function() {
    
            $("#aLink").fancybox({
                'width'             : '75%',
                'height'            : '75%',
                'autoScale'         : false,
                'transitionIn'      : 'none',
                'transitionOut'     : 'none',
                'type'              : 'iframe'
            });
        });
    </script>
    
    <body onload="$('#aLink').trigger('click');">
    <a id="aLink" href="http://www.google.com" ></a>
    For the curious, the reason i only want them to see it once is because its a brief how to video in the window!


    Thanks you in advance


    embeebutterly

  • #2
    Setting and clearing cookies with jQuery is really easy (especially when compared with regular Javascript) but it's not includedin the jQuery core and requires a plug-in. This post shows how to set, get the value of and clear cookies with jQuery.


    Get that plugin.

    And you should be able to fire it like:
    Code:
            $("#aLink").fancybox({
                'width'             : '75%',
                'height'            : '75%',
                'autoScale'         : false,
                'transitionIn'      : 'none',
                'transitionOut'     : 'none',
                'type'              : 'iframe',
                'ajax' { $.cookie("example", "foo"); } 
            });
    my syntax for the ajax in fancybox might be wrong.

    That should set the cookie when fancybox is fired.
    Stop making things so hard on yourself.
    i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎