By toddtomlinson on
I am using Lightbox2 to display a form and on submit - I would like to close that window. I've searched and searched and can't find a programmatic way to close the window. Has anyone succeeded in doing this?
I'm trying to keep the user from having to click submit and then click the X to close the window.
Comments
subscribing
subscribing
MfG
CKIDOW
subscribing
subscribing
Cheers,
Anil Sagar,
Lead Drupal Developer,
Azri Soulutions,
http://azrisolutions.com/
subscribing
subscribing
I too have looked all over
I too have looked all over for this, but haven't found a way yet. I suspect the answer will lie in somehow using the javascript command close.window(), ie:
Then somehow get an onSubmit attribute into the form tag. I'll post a followup if I get this working.
- Ryan
A way to solve this
Hello, I found a way to solve this using Login Toboggan which can be configured to redirect the user to a specific page after registering. In the settings page of Login Toboggan, in the field where you put the redirect URL I specify a node which I previously created with the following script as the content:
<script>window.parent.Lightbox.end();</script>Remember to enable full HTML so it actually executes this code.
I don't know if there is a better way to do this, but for now this is working for me.
confirming that this works
confirming that this works for programmatically closing lightbox (2)
used this for closing down lightbox webform after validation.
So , put this in the
"Additional Processing" field of the "Webform advanced settings"
<?php
window.parent.Lightbox.end();//Close lightbox webform when done
print "
";
close lightbox
how to close the lightbox using a cancel button??
http://drupal.org/node/135721
http://drupal.org/node/1357218
put the js (
parent.Lightbox.end();) on event js like onclick in hook form_alter.The problème of this thing is that the validation of form is not verify, it's just close the Lightbox even if the form is not validate.
You can also make onSubmit but for me, i want to redirect just after closing lightbox and so the Onsbmit is execute after the redirection so you are redirect but in the lightbox.
The last way (that i know) is that to put in form attributes, target equal _top, but i use content_page in the lightbox (to have only the content of page). And when your form is not validate, your lightbox close but you are redirect to form without the wrapper of page (there are only form in a page).
So if somone know how to close lightbox and redirect after if the form is validate.
After much trial and error
After much trial and error this is what I did to get lightbox close and redirect on href click, but not when lightbox is closed on it's own
The circumstances in which I use it are as follows:
I have a main products page (a node with my custom php code to display a list of products and when clicked, displays details about the specific product) with a lightframe of a blurb about that product that appears when you click on the picture of the product - but not the surrounding table cell or links to the detailed product content. The lightframe content links to a separate PHP page (blurb.php) I have in my drupal install directory which loads Drupal session data and only displays the page to authenticated users. The code around the image is:
<a href="' . $product_link . '" rel="lightframe[|width:550px; height:295px;]">The blurb.php page then contains the reduced data I want to display. At the bottom, I have a "Visit the full page" link which links back to the main node to display the full product content there (or to whatever you want).
<a href="' . $base_url . '/' . $product_url_link . '" onclick="parent.window.location=\'' . $base_url . '/' . $product_url_link . '\'; parent.Lightbox.end();">Visit full product page...</a>Hope this helps!
lightbox.end()
lightbox.end()
lightbox is a global var
onclick="parent.Lightbox.end(
onclick="parent.Lightbox.end();"