This is a quick look at how to open and/or launch jQuery Fancybox on page load.
If you want Fancybox to open each time the page loads all you need to add is:
$(".fancybox").fancybox().trigger('click');
That being said, you probably don’t want it loading every time you go to that page. That could get pretty annoying!
Below is a simple way to add a cookie to it. When adding this cookie to Fancybox you will only see Fancybox load on the page when you first visit it in that current browser session.
var key_value = "myTestCookie=true"; var foundCookie = 0; var cookieArray = document.cookie.split(';'); for(var i=0;i < cookieArray.length;i++) { var checkCookie = cookieArray[i]; while (checkCookie.charAt(0)==' ') { checkCookie = checkCookie.substring (1,checkCookie.length); } if (checkCookie.indexOf(key_value) == 0) { null foundCookie = 1; } } if ( foundCookie == 0) { // The key_value cookie was not found so set it now document.cookie = key_value; $(".fancybox").fancybox().trigger('click'); }
Hope this helps in your search and implementation of what you are looking for!