jQuery Cookie function only works in FireFox browser

Monday, July 7, 2014

I have following block of code which behaves different in different browsers.


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



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 });
}

}


First: It works perfectly in Firefox Private broswer mode. It show the Fancybox banner once & then it doents show it again on home page unless i dont close the browser & start it again.


Second: FireFox normal mode it don't show fancybox at all.


Same happens with IE & Chrome.


I am not sure what is wrong with the script.


I goal is to show the fancybox banner only once per user browser session. Banner is on home page it should show it first time he visits the home page and if visit the home page second time during the same session then banner should not show up.


Any help is appreciate.







http://ift.tt/1vQqXTS