In fact, none of the solutions published earlier work in real life, why? because the line:
$("#various1").fancybox();
doesn't start fancybox, it just binds fancybox to the # different1 selector, but it still needs a click to bring up the modal / lightbox (and not the popup). BTW, Gearรณid's solution has syntax errors anyway. The only real value is that they suggest using a jQuery cookie (old site).
EDIT : (March 07, 2012) The jQuery cookie plugin home page has been moved here .
Steps for a working solution:
A) Download the jQuery cookie plugin (as suggested) after jQuery and fancybox js files
B) Then use this script:
<script type="text/javascript"> function openFancybox() { setTimeout( function() {$('#various1').trigger('click'); },20000); } $(document).ready(function() { var visited = $.cookie('visited'); if (visited == 'yes') { return false; } else { openFancybox(); } $.cookie('visited', 'yes', { expires: 7 }); $('#various1').fancybox(); }); </script>
C) you still need somewhere in your html code (possibly hidden)
<a id="various1" href="path/target"></a>
or for embedded content
<a id="various1" href="#target"></a> <div style="display: none;"> <div id="target">message to display in fancybox</div> </div>
In addition, if you use embedded content and fancybox v1.3.x, check for an existing error and a workaround here
PS. fancybox is not a popup, but a jQuery modal / lightbox plugin, which is a non-intrusive solution like jGrowl from a UI perspective.