1

I have two banner one page one which is top one on page i show this one as slide down banner and i can show this banner once per browser session using following script

<div class="welcome">
    <div>
    <h1>Hello..!<br> Welcome to ABC
    <br>
    </h1>
    <h2>We wish you a Great Day..!</h2>
    <br>

    <h2><a id="close-welcome" href="#">Thank you.. and please take me to the     website</a> </h2>
    </div>
   </div>
<script type="text/javascript" src="https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js"></script>
   <script>
$(document).ready(function() {
    if ($.cookie('noShowWelcome')) $('.welcome').hide();
    else {
        $("#close-welcome").click(function() {
            $(".welcome").fadeOut(1000);
            $.cookie('noShowWelcome', true);    
        });
    }
});
</script>

This works fine but i have another Fancy-Box banner which shown an Image Banner

<a href="#" class="fancybox-messageboard" style="display:block;"><img src"http://upload.wikimedia.org/wikipedia/commons/1/1a/Bachalpseeflowers.jpg"/></a>

I want to do same for the above fancy-box banner it should also show only once per browser session.

UPDATE:

I have modified my code to make it work with jQuery.Cookie

This code below is intend to show Fancybox only once per browser session and this code works fine in firefox Private mode only.

 if (window.showMessage) {
            alert('1');
            var visited = $.cookie('visited2');
            if (visited == 'yes') {
                alert('a');
                return false;
            } else {
                alert('b');
                //openFancybox();
                $("a.fancybox-messageboard").fancybox({
                    width: 600,
                    height: 440,
                    closeClick: false,
                    hideOnOverlayClick: false,
                    href: imgPath,
                    helpers: {
                        overlay: { closeClick: false} // prevents closing when clicking OUTSIDE fancybox 
                    }
                }).trigger('click');
                $.cookie('visited2', 'yes', { expires: 7 });
            }

        }

Problem with the above code is that it works only in Firefox Private mode only it downt show popup in IE or Chrome not event in private mode also.

I am not sure what it behaves like that.

TessellatingHeckler
  • 27,511
  • 4
  • 48
  • 87
Learning
  • 19,469
  • 39
  • 180
  • 373
  • @JFK, I missed very important part of question that i have other fancybox elements on this page which should always show when user click on the for example image gallery, or a Video... For this reason i only want only element with class `fancybox-messageboard` to show only once during each session not the other fancybox elements – Learning Jul 06 '14 at 04:30
  • then refer to the duplicated question and trigger the `click` on that selector only (I assume the other elements bound to fancybox are using another selector, aren't they?) – JFK Jul 06 '14 at 04:33
  • Yes they, Let me try.. Thanks – Learning Jul 06 '14 at 04:35
  • @JFK, I changed the script & update my question but script is behaving wired in it works only in FF private mode & in normal mode it doesnt show fancybox at all. – Learning Jul 07 '14 at 08:11
  • well, then it's working fine ;) ....it works in private mode because it doesn't store cookies otherwise the cookie is active. you need to clear your cache to make it work every time in normal mode – JFK Jul 07 '14 at 08:47
  • I clear all my cache, But i have problem IE & Chrome their it doen't work on private mode either. – Learning Jul 07 '14 at 09:54

0 Answers0