Launch window onload? Can this be done?
Patrick,
Try storing a reference to the modal in a variable when you create the modal, then call .open() on that reference.
Something like the following (written off the top of my head, not tested!):
Event.observe(window, 'load', function() {
// create your modal, storing a ref to it in myModal
var myModal = new Control.Modal(false, {
// your modal properties here
});
// manually open myModal
myModal.open();
});
If you still want the link on the page, you can leave the reference to it in there, but the above will pop the modal open without it being associated with an anchor. I'm guessing this is what you want - if the modal is to open on load, there's probably no point in having a link to it?
I've used this approach in the past to forcibly show a login form in a modal, if I detect that the visitor isn't logged in. This works well in combination with "overlayCloseOnClick: false", to prevent people from ignoring the login prompt.
Hope that helps!
Ben
Posted August 23rd, 2007 at 5:10am by bbodien
Hi,
I currently launch modal windows like this:=============================================
Is it possible to launch a hyperlink like this or window event without having to click, so onload or something along those lines? I have tried various methods but none seem to work giving the sort of lightbox effect.
Thanks, Patrick
Posted August 16th, 2007 at 1:44pm by pmccarthy