Forum Moderators: open

Message Too Old, No Replies

Lightbox splash

         

SilverLining

3:31 pm on Dec 9, 2009 (gmt 0)

10+ Year Member



Hi there,

I'm having trouble setting up a lightbox splash page. The lightbox functionality works well when I have an image with a surrounding href and specified rel

e.g.

<a href="image.gif" rel="lightbox" id="splash-image"><img src="image.gif" width="200" height="200" alt=""/></a>

but what I'm trying to achieve is when the page is visited the lightbox frame will be expanded, displaying the above image. (The image should not be visible on the actual index.php page, so possibly set the style to display:none)

How can I execute the onclick event for that link once the document has loaded?

I'm not intending to use cookies for this, because the idea is to only display the image on the home page, which has it's own template.

Is there a better way of doing this? I haven't posted any of the Lightbox code, because I'm assuming most of you know the funtionality. Also, I didn't feel it necessary to include dtd and other html.

Extract from lightbox.js


function addLoadEvent(func)
{
var oldonload = window.onload;
if (typeof window.onload != 'function'){
window.onload = func;
} else {
window.onload = function(){
oldonload();
func();
}
}
}
addLoadEvent(initLightbox); // run initLightbox onLoad

Thanks for any replies.

Fotiman

3:55 pm on Dec 9, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Does it work if you do this:

addLoadEvent(function () {
showLightbox(document.getElementById('splash-image'));
});

SilverLining

7:05 am on Dec 11, 2009 (gmt 0)

10+ Year Member



Thanks Fotiman. That does work, but needs some tweaking. I may need cookies after all.