View Full Version : Call a function from an opened div layer

Mar 1st, 2007, 04:22 PM

I am using GreyBox (http://orangoo.com/labs/GreyBox/) (which is a lightbox kind of popup window layer) on one of my sites.

On the site, somewhere I use Panels (div layers) that appear when
clicked on a link and give me options.

Keep it simple, this is how I call a panel (There is some PHP involved
but ignore it):

<a id="panel$ID" href="#" onClick="return Panel($ID, $title);">$title</a>

and my JS function is as follows:

function Panel(id,title) {
if (PanelLoaded[id]) {
return false;
PanelLoaded[id] = true;
contBoxid = 'panel'+id;
var contBox = document.getElementById(contBoxid);
box = document.createElement('div');
box.className = 'contbox';
box.id = 'contbox'+id;
box.style.cursor = 'default';
box.style.position = 'absolute';
box.style.marginTop = '5px';
box.style.marginLeft = '10px';
box.style.padding = '5px';
box.style.width = '280px';
box.style.textAlign = 'left';
box.style.backgroundColor = '#003366';
box.style.border = 'solid 1px #000000';
box.style.MozBorderRadius = '7px';

box.innerHTML = ''+
'<table class="table_panels" cellspacing="0">'+
'<td class="ptitle" colspan="3">'+title+'</td>'+
'<td><img src="images/panels/info.gif" alt="Info"></td>'+
'<td><a href="books.php?op=showbook&bid='+id+'"
'<td><img src="images/panels/list.gif" alt="List"></td>'+
'<td><a href="mylists.php?bid='+id+'" title="My Lists"
rel="gb_page_center[400, 300]" onClick="closePanel('+id+');">View
'<td><img src="images/panels/comments.gif" alt="Make Comment"></td>'+
'<td><a href="books.php?op=showcomments&bid='+id+'&sel=2"
'<td><img src="images/panels/close.gif" alt="Close Panel"></td>'+
'<td><a href="#" onClick="return closePanel(\''+id+'\')">Close</a></

return false;


function closePanel(id) {
boxid = 'contbox'+id;

PanelLoaded[id] = false;
return false;


If you look at the Lists part - this is where call the GreyBox function with rel attribute.

If I load the page and click on the link, the Panel comes up and when
I click "View Lists", GreyBox does not come up, instead the browser
loads the page that GreyBox should have loaded.

So, how can I call the gb_page_center from this panel? I tried adding
parent and parent.parent before gb_page_center but it did not help.

Any help is highly appreciated.