Needs review
Project:
Lightbox2
Version:
6.x-1.8
Component:
User interface
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
24 Nov 2008 at 18:25 UTC
Updated:
30 Aug 2011 at 21:37 UTC
Hi,
I'm trying to add a 'close' button inside of an html page that I'm using lightbox2 with (via iframe, i.e. "rel=lightframe"). I've tried adding some jquery code to the head of the embedded HTML page, attaching a click event to the button I've put in my HTML content. But, even though I can get this to trigger something stupid like an alert box, it will not close the lightbox window when I attach "Lightbox.end('forceClose'); return false;" to it instead. What am I doing wrong?
Thanks!
Best,
Dave
Comments
Comment #1
stella commentedIt's not possible to do this. Browsers don't allow it as a means to help prevent cross-site scripting.
If you have control over the html content being displayed in the lightbox2, and if it is on the same domain as the page where the lightbox is being opened, then you could try
rel="lightmodal". For this to work in all browsers with no unexpected problems or errors, the html code in the modal dialog should not include<html>,<body>, or similar tags. This is because the content displayed in a "lightmodal" is placed inside a div in the current page. However, because it's inside the current page and not an iframe, it should be possible to close the lightbox from within the loaded page.Cheers,
Stella
Comment #2
dubitable commentedHi Stella,
Thanks for the quick response. I figured as much; but I appreciate you confirming this for me.
Thanks!
Best,
Dave
Comment #3
leksat commentedDon't sure it will work for all browsers...
Add javascript function (global) in your main window which will close lightbox. Like this:
Now you can create button in your iframe. Like this:
<input type="button" onclick="javascript: window.parent.close_iframe(); return false;" value="Close">The main thing is
window.parent.close_iframe();.Comment #4
cgoren commentedHi,
Try adding onclick="parent.Lightbox.end('forceClose');" to the link.
Enjoy
Chen @ Creative Team