View Full Version : How to close dhtml window on click of a button?

11-30-2008, 09:49 AM
1) Script Title: dhtmlwindow

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/

3) Describe problem: I open a new dhtml window with iframe option along with a URL. URL is a HTML page having some text and a button. How can I close the dhtml window on click of this button? Also how can I call Javascript functions written on the parent page from dhtml window?

11-30-2008, 11:00 AM
Just fixing the link:


12-01-2008, 08:04 AM
Please do a search- how to have code inside a DHTML window call a function from the opening parent window has been answered many times. Regarding your question, assuming you've opened your window using something like:

var mywindow=dhtmlwindow.open("mybox", "iframe", "test.htm", "Test site", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")

On test.htm, the code to close this DHTML window would be:


In other words, add "parent." in front of the DHTML window's variable to refer to it from the DHTML window page. Same goes for accessing variables in the parent window.