Hi Stella!
I'm looking for a way to invoke a lightbox immediately on page load, as opposed to on clicking a link.
Something tells me this is obvious, but I can't get my head around it.
As a part two, I need to limit this to 'popup' to be a once off.
[I need to show a once-off notice to website visitors, regardless of which page they enter on.]
Any ideas?
Regards
Alan
PS Hopefully We'll meet up at the Dublin Drupal thing...
Comments
Comment #1
stella commentedHi Alan!
Unfortunately it's not really possible with the Lightbox2 module. It requires an anchor link click event. However, you could do something like the following:
* Create a link (hidden if you wish) and put it in the page footer or something that is included on each page. This link would need a
rel="lightmodal"orrel="lightframe"type attribute if you want to display text in the lightbox.* Create a small js file which is loaded on each page (can do this in your theme with drupal_add_js()). The js file would need to use the jQuery function triggerHandler() to trigger the click event on that link, maybe something like (untested):
where #anchor_id is the value of the id attribute you've set on the link.
You might also want to check out the Slidebox module. I think it provides this functionality, but there's only a Drupal 5 dev version and it doesn't work in all browsers - see the lightbox-type module comparison article I did at http://drupal.org/node/266126.
Hope this helps!
Cheers,
Stella
p.s. I'll probably see you in Szeged before the Dublin Drupal thing gets off the ground :)
Comment #2
alanburke commentedQuick work Stella,
triggerHandler(), with the click event, will do the trick to invoke the popup alright.
I won't get a chance to test it fully for a while though.
Any ideas on how to limit it to once per visitor?
Regards
Alan
PS Roll on Szeged!
Comment #3
stella commentedAh that's trickier. Hmmm, maybe store a variable in the session, i.e. set a flag which basically says popup already displayed for this session. Not sure how easy that will be to do. IIRC javascript can't modify the session args, so you'd need something in your php code that will only display the (hidden) link on the site if it hasn't been displayed to that user already. If the link doesn't exist on the page, then no click event can be triggered for it and so no popup will be displayed.
If you get it to work, it might be a good idea to write a little example to the lightbox2 docs at http://drupal.org/node/144469
Cheers,
Stella
Comment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.