Question: I want to set a timer for the reload of my iframe, but the timer will only start when the user clicks the button. Is there any way to do it? My code refreshes the iframe every 3 seconds instead of onclick.

code:

```
function reloadIFrame() {
     setInterval(function(){window.frames['frame'].location.reload();},3000);
}

```

button:

```
 <input type="submit" value="Save" onclick="reloadIFrame()"/>

```

I want the iframe to refresh after 3 seconds when the user clicks the button.

Answer: 
I think you need `setTimeout` instead of `setInterval`

```
function reloadIFrame() {
   setTimeout(function(){window.frames['frame'].location.reload();},3000);
}

```
Seems that you just want to put a delay on the action. What you are doing is using the setInterval which will run the function every three seconds. You are looking to set a delay, you should use, in that case you should use the setTimeout function.

```
 setTimeout(function(){window.frames['frame'].location.reload();},3000)

```