View Full Version : fancybox showing once with Javascript Cookies

09-02-2010, 04:29 PM
Hello guys!
I have a jquery fancybox that pop's up on exit (using onbeforeunload), now i want it to show only once so i tried doing it with cookies but i just can get it to work. this is my script so far hope you can help me with this, Thanks!

<script type="text/javascript">
function PopIt()
if (document.cookie.length == 0)
var exdate=new Date();
document.cookie="cook=yes" + ";expires="+exdate.toUTCString();

window.onbeforeunload = UnPopIt;
return "Before you leave:\nPlease take a few seconds to answer 2 questions\nso we can better assist you and others in the future. \nThanks!";

function UnPopIt() { /* nothing to return */ }

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

'hideOnContentClick': false,
'showCloseButton': true

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