PDA

View Full Version : Trying to close a window within itself.



Eric Saboia
02-02-2007, 03:43 AM
Hi,

I'm using Popup Windows ( http://www.dynamicdrive.com/dynamicindex11/abox2.htm ), and I need to close a window generated by it within the window itself. I've tried to use hidebox(ID), but it only works on a opened popup. Can anyone help me?

Thanks.

Regards,

Eric Saboia

jscheuer1
02-02-2007, 04:38 AM
Why would you want to close an unopened pop up?

Eric Saboia
02-02-2007, 12:34 PM
I should right opener (parent document) and not opened. Im sorry.

jscheuer1
02-02-2007, 03:55 PM
I'm still not clear on where you are trying to do what from.

I think the what is - close a pop up pseudo window created by this script.

I think where is from some other window other than the one in which the pop up pseudo window created by this script resides.

Cross window scripting is fairly easy but, can get tricky when windows are opened and closed and/or reused after being initially created. The basic idea is that anything on the child window can be accessed from the opener if it was opened using javascript and assigned a variable at that time:


var mynewwin=window.open('some.htm');

Now, from the page (not the window) that opened some.htm in this manner, things on some.htm become (for example its document.title becomes):


mynewwin.document.title

Going in the other direction is even easier. To access something on the parent window from the child, it makes no difference how the child was opened, the parent is always (on the child window's page) the opener. The parent's title would be (from the child):


opener.document.title

Eric Saboia
02-02-2007, 08:41 PM
index.php:
new popUp(0, 0, 773, 385, unique, "<iframe src='"+acao+"_prod.php?id_prod="+id_prod+"&id_div="+unique+"' name='main' width='100&#37;' height='100%' marginheight='1' scrolling='Auto' frameborder='0' id='main'></iframe>", "white", "black", "bold 10pt sans-serif", "Informa&#231;&#245;es do produto", "navy", "white", "#dddddd", "gray", "black", true, false, false, true, false);

I want to close (or hide) the popUP using a link inside the acao_prod.php (iframe link thats loaded inside the pseudo window). Just like the [x] on titlebar of pseudo window.

Sorry for the bad english..

jscheuer1
02-02-2007, 09:13 PM
That's a little different. You are not dealing with an opener or with a child window created as I indicated. You can still do it. What you have is a parent page:

index.php

and a child iframe:


<iframe src='"+acao+"_prod.php?id_prod="+id_prod+"&id_div="+unique+"' name='main' width='100%' height='100%' marginheight='1' scrolling='Auto' frameborder='0' id='main'></iframe>

This child iframe contains a page:

acao_prod.php

on acao_prod.php things on index.php would be parent.object so, from my previous example, index.php's title would be from acao_prod.php:

parent.document.title

and what you seem to be after would be:

parent.hidebox(ID)

Eric Saboia
02-02-2007, 11:46 PM
Thanks!! ;)