Joseph Zammit Joseph Zammit - 1 year ago 95
Javascript Question

refresh on setTimeout

I have a javascript set timeout to close a div after 10 sec and I want to add a page refresh when the div is closed. The code I'm using is below.

var container_close_sec = "100";
var closeTime = container_close_sec * 100;

setTimeout("parent.close_div()", closeTime);



Answer Source

Try this:

var container_close_sec = 100;
var closeTime = container_close_sec * 100;

setTimeout(function() {
    parent.close_div(); // Closes div
    location.href = location.href; // Refresh page
}, closeTime);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download