HI,
I am quite new to javascript but with the help of jscheuer1's comment in this thread I managed to get a Lightbox 2.04 working to display a single image when a page loads.
Basically I put thisat the end of the xhtml-code on my landing page, and then added two lines of code to the lightbox.js, so that it looks like this:HTML Code:<div><a id="lightboxPopImage" href="images/welcome_first_timer.jpg" rel="lightbox"></a> </div>
This way I get a lightboxpopup every time the page loads.Code:var th = this; (function(){ var ids = 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; $w(ids).each(function(id){ th[id] = $(id); }); if (document.getElementById('lightboxPopImage')) { th.start(document.getElementById('lightboxPopImage')); } }).defer(); },
But of course I would like to take it one step further, and use a cookie to control that this lightbox effect is only performed once per day. I have been battling with trying to implement a cookie solution all weekend but just have not got it to work (even started to look at PHP cookies in my desperation).
I think I just need a very simple routine inside the lightbox.js that checks for the existence of a cookie, and if it finds a cookie it skips the parts in the script where it shows the image, and just aborts the script altogether.
And then at the end of lightbox.js I guess I need to create the cookie in question (with a longevity of 1 day). At the end since I want to give the lightbox the chance to execute for a first time visitor before the cookie is created.
Is this difficult? Is it much to ask for help on this matter?
I would be very happy to get some pointers.
I enclose the full sized lightbox.js
Thanks a lot from Sweden!



Reply With Quote

Bookmarks