View Full Version : Problem with dhtml modal window

03-08-2007, 01:05 PM
1) Script Title: DHTML modal window

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

3) Describe problem:
Hi, I'm using the script above to display iframes.
I would like to include a script in an IFRAME that would close this iframe automatically (do the same than : when you click on the cross), or reload the opener window.
Can anyone help?

Thanks ;)

03-09-2007, 03:49 AM
The docs on the script page actually already discusses how to do the first thing, that is, refresh the iframe automatically. Assuming the below is the HTML of your iframe page:

<h4>Sign up for our newsletter!</h4>
<form id="myform">
<p>Enter your email address please:<br>
<input id="emailfield" type="text" name="T1" size="30" />
<input type="button" value="Ok" name="B1" onClick="parent.emailwindow.hide() " /></p>

Here the code in red creates a custom "Close button". To create code that auto closes the window after x seconds, you would change it to something like:

<script type="text/javascript">

//Close window after 3 seconds
setTimeout("parent.emailwindow.hide()", 3000)


To auto refresh the iframe after x seconds, do this instead:

<script type="text/javascript">

//Refresh window after 3 seconds
setTimeout("window.location.reload()", 3000)


Both of the above scripts need to go inside the iframe page.