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.