diff --git a/lib/javascript-static.js b/lib/javascript-static.js index 184ef84978c..904cd4575a1 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -1061,17 +1061,6 @@ function close_window(e) { window.close(); } -/** - * Close the current browser window, forcing the window/tab that opened this - * popup to reload itself. */ -function close_window_reloading_opener() { - if (window.opener) { - window.opener.location.reload(1); - close_window({}); - // Intentionally, only try to close the window if there is some evidence we are in a popup. - } -} - /** * Used in a couple of modules to hide navigation areas when using AJAX */ diff --git a/lib/weblib.php b/lib/weblib.php index 69b13a4bad7..c9ba974fab5 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -823,13 +823,12 @@ function close_window($delay = 0, $reloadopener = false) { } if ($reloadopener) { - $function = 'close_window_reloading_opener'; - } else { - $function = 'close_window'; + // Trigger the reload immediately, even if the reload is after a delay. + $PAGE->requires->js_function_call('window.opener.location.reload', array(true)); } - echo '

' . get_string('windowclosing') . '

'; + $OUTPUT->notification(get_string('windowclosing'), 'notifysuccess'); - $PAGE->requires->js_function_call($function, null, false, $delay); + $PAGE->requires->js_function_call('close_window', array(new stdClass()), false, $delay); echo $OUTPUT->footer(); exit;