Ever wanted to automatically start Lightbox so that it shows an image immediately after the page has loaded? It’s possible!
Lightbox.js, which will of course break when a new version is released (it’s never a clever idea to edit core files).
I took the freedom to modify the implementation a bit (the core hasn’t changed though): Instead of editing your
Lightbox.js file, you only need to modify your HTML
head element so that it includes the extra functionality of kickstarting Lightbox:
Note #2: the reason we’re calling a
setTimeout (a 250 milliseconds delay) is to fix an issue in IE where the variable
myLightbox would be non-existent immediately after page load.
Note #3: getting a
myLightBox is undefined error? Great, you’re using the most recent Lightbox version … and that one requires 1 tiny fix 😉
To now use this functionality make sure you have given your
a-element an id …
<a href="images/image-1.jpg" rel="lightbox" id="image001"><img src="images/thumb-1.jpg" width="100" height="40" alt="" /></a>
… and then call the page by adding a # followed by that id:
That’s it, you’re done!
A working demo can be found over at https://www.bram.us/demo/projects/autofirelightbox/#image001
To make things complete: this will not work with flashLightBoxInjector as the swf (or a return from your AJAX call, that’s possible too you know), dynamically builds a list of linked images when the swf is loaded/call has been returned.
I don’t run ads on my blog nor do I do this for profit. A donation however would always put a smile on my face though. Thanks!