Question : using setTimeout with window.opener.location.reload();

There are multiple posts on the web about this same issue, but none with a clear resolution. Here's the issue:

I have a parent window that opens a child which contains a list of reports that a user can click. When the user clicks a report in the child, a url is invoked in the child which tells the server to add that report to the list of users desired reports. The child should then close and the parent should refresh.

Due to the nature of the application, I want the parent to pause briefly (500ms or so) for the server to add the report to the list of desired reports on the server before refreshing. I understand that some may consider this bad programming, but without getting in to the particulars, it is the only way to accomplish what I need to do (there are multiple hosts and legacy languages involved... trust me) so please focus on the javascript and not on my "flowchart".

I've tried wrapping the setTimout in a function, etc. with no luck. It works fine except that there is no pause - it immediately refreshes the page.

Here is the child html. I'm not sure the parent's html would be helpful:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Select a Report</title>
<style media="all" type="text/css">@import url('../css/styles.css');</style>

<script LANGUAGE="JavaScript">

function addSched(sched){
  window.location = "get.mv?PAGE=ALERT&MODE=RETRIEVE&ALERT_ID=5000.1&ADD_SCHED=" + sched;
  setTimeout(function(){window.opener.location.reload(true);}, 500)
  self.close();
}
</script>

</head>
<body>
<table>
    <tr>
        <th>Schedule Number</th>
        <th>Schedule Name</th>
        <th>Accounts</th>
    </tr>
    <tr>
        <td><a href="javascript:addSched('PLC 2');">2</td>
        <td><a href="javascript:addSched('PLC 2');">CASH IN BANK</td>
        <td>202,202F,202L</td>
    </tr>
    <tr>
        <td><a href="javascript:addSched('PLC 3');">3</td>
        <td><a href="javascript:addSched('PLC 3');">AR VEH DEPOSIT</td>
        <td>220A,220B</td>
    </tr>
</table>
</body>
</html>

Answer : using setTimeout with window.opener.location.reload();

This point is that if you change your url (window.location) or if you reload the page, any running script is aborted and replaced by the new page.
Random Solutions  
 
programming4us programming4us