diff --git a/lib/weblib.php b/lib/weblib.php
index 0bf3b5f40b0..2d479110987 100644
--- a/lib/weblib.php
+++ b/lib/weblib.php
@@ -2720,6 +2720,33 @@ function print_js_call($function, $args = array(), $return = false) {
}
}
+/**
+ * Generate the HTML for calling a javascript funtion after a time delay.
+ * In other respects, this function is the same as print_js_call.
+ *
+ * @param integer $delay the desired delay in seconds.
+ * @param string $function the name of the JavaScript function to call.
+ * @param array $args an optional list of arguments to the function call.
+ * @param boolean $return if true, return the HTML code, otherwise output it.
+ * @return mixed string if $return is true, otherwise nothing.
+ */
+function print_delayed_js_call($delay, $function, $args = array(), $return = false) {
+ $quotedargs = array();
+ foreach ($args as $arg) {
+ $quotedargs[] = json_encode($arg);
+ }
+ $html = '';
+ $html .= '\n";
+ if ($return) {
+ return $html;
+ } else {
+ echo $html;
+ }
+}
+
/**
* Sometimes you need access to some values in your JavaScript that you can only
* get from PHP code. You can handle this by generating your JS in PHP, but a
@@ -6144,7 +6171,7 @@ function redirect($url, $message='', $delay=-1) {
@header('Location: '.$url);
//another way for older browsers and already sent headers (eg trailing whitespace in config.php)
echo '';
- echo ''; // To cope with Mozilla bug
+ print_js_call('document.location.replace', array($url));
die;
}
@@ -6164,17 +6191,7 @@ function redirect($url, $message='', $delay=-1) {
echo '';
if (!$errorprinted) {
-?>
-
-docroot = false; // to prevent the link to moodle docs from being displayed on redirect page.
diff --git a/message/refresh.php b/message/refresh.php
index b2c10748759..009c7c3a110 100644
--- a/message/refresh.php
+++ b/message/refresh.php
@@ -129,18 +129,8 @@
}
// Javascript for Mozilla to cope with the redirect bug from editor being on in this page
- ?>
-
-
-
-