...

View Full Version : cookies with jquery



dubek
09-05-2010, 11:53 AM
Hello here
I'm trying to make my fancybox on exit pop up run only once using cookies but it keeps showing every time i refresh or back the page. (I installed cookies plugin and fancybox plugin).
It seems like the cookie isn't getting value, like its null all the time.
This is my code maybe you can help me here. Thanks!

<script type="text/javascript">
function PopIt()
{
var COOKIE_NAME = 'cook';
if($.cookie(COOKIE_NAME) != 'active')
{
$.cookie(COOKIE_NAME, 'active', { expires: 7 });
$("a#trigger").trigger('click');
window.onbeforeunload = UnPopIt;
return "Before you leave:\nPlease take a few seconds to answer 2 questions";
}
}
function UnPopIt() { /* nothing to return */ }

$(document).ready(function() {
window.onbeforeunload = PopIt;

$("a#trigger").fancybox({
'hideOnContentClick': false,
'showCloseButton': true
});

$("a[id!=trigger]").click(function(){ window.onbeforeunload = UnPopIt; });
});
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum