View Full Version : can't close iframe launched by function

07-29-2008, 01:50 PM
1) Script Title:
can't close iframe launched by function

2) Script URL (on DD):

3) Describe problem:

I want to use the iframe window widget but I'm stuck trying to create a link inside the iframe that closes the dhtml window.

For my purposes, I need the dhtml window appear only when I click on an icon and not instantly when loading page, so I've used this code on my main file:

function popup(){
var googlewin=dhtmlwindow.open("googlebox2", "iframe", "window2.htm", "#1: Google Web site", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")

With this code, If you close the dhtml with the X button and you want to open it again without reloading the page, you won't get any error.

In the dhtml window I want to close the dhtml window (after doing other things) clicking on a link, so initially the code in the dhtml window was:

function hidedhtml(){

The problem at this point, is that if you have the dhtml window var inside a function in the main file, the function in the iframe doesn't know the id of the dhtml window so I can't close it.

Does anybody know what code should I put in the iframe to close the dhtml window in this case?

Thanks in advance.



07-29-2008, 05:34 PM
If you put the variable into the global scope, it should all work without additional changes:

var googlewin;
function popup(){
googlewin=dhtmlwindow.open("googlebox2", "iframe", "window2.htm", "#1: Google Web site", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")

07-29-2008, 05:46 PM
yeah! It works. I've found also another thread with a similar answer:


I've been looking for this the whole day. I think I've to learn some javascript basics before modifying scripts...

Thank you! :)