View Full Version : Window Widget - Closing window from inside window

06-28-2007, 03:02 PM
1) Script Title: DHTML Window widget (v1.03)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ndow/index.htm

3) Describe problem:

I am using the script to popup a window pulling the content from an iframe, but I want to put a link inside that iframe that can close that popup window. The script that is provided in the notes tells me how to close the window from the 'opener' using googlewin.hide() but I can't use this in the iframe content itself.

Can anyone tell me how I close/hide the popup with a link inside the iframe html?

If I put <a href="#" onClick="googlewin.hide(); return false;">Hide Window</a> I get an error saying googlewin is not defined.


06-28-2007, 06:36 PM
Try something like:

<a href="#" onClick="parent.googlewin.hide(); return false;">Hide Window</a>

The code in red is new.

08-18-2007, 12:32 PM

Your solution didn't seem to do it over here... I have a DHTML iframe window called with this link action:

onclick="var winError=dhtmlwindow.open('winError', 'iframe', '_sys/winError.inc.htm', 'Rapporter feil', 'width=300px,height=200px,center=1', '')"

I've added the following code in the iframe HTML, hoping to close the window:

onclick="parent.winError.hide(); return false;"
...But it failed, and returned the following error:

parent.winError has no properties

Anybody out there with a solution to this? I simply don't get it :p

08-18-2007, 01:36 PM
My guess would be, if everything else is right, which it appears to be (except that you should probably return false from the opening onclick event as well), that since onclick events are technically functions and any variables declared in them will only be available to them, you need to get your:

var winError

into the global scope. There are various ways. I'd recommend doing it like so:

onclick="window.winError=dhtmlwindow.open('winError', 'iframe', '_sys/winError.inc.htm', 'Rapporter feil', 'width=300px,height=200px,center=1', '');return false;"

Then hiding it like so (from within the iframe):

onclick="parent.window.winError.hide(); return false;"

There could also be other problems.

08-18-2007, 02:02 PM
Straight out brilliant, John! That did the trick, thanks a lot :)