]> git.mjollnir.org Git - moodle.git/commitdiff
Make the close_window function better. Merged from MOODLE_17_STABLE.
authortjhunt <tjhunt>
Tue, 31 Oct 2006 11:59:54 +0000 (11:59 +0000)
committertjhunt <tjhunt>
Tue, 31 Oct 2006 11:59:54 +0000 (11:59 +0000)
lang/en_utf8/moodle.php
lib/weblib.php

index 2410252cc26ed9a0ee06f79c0aae2010fd86b994..34896171aa7e2f417851a5830001e8a528ba05aa 100644 (file)
@@ -1047,6 +1047,7 @@ $string['periodending'] = 'Period ending ($a)';
 $string['personalprofile'] = 'Personal profile';
 $string['phone'] = 'Phone';
 $string['phpinfo'] = 'PHP info';
+$string['pleaseclose'] = 'Please close this window now.';
 $string['pluginsetup'] = 'Setting up plugin tables';
 $string['policyagree'] = 'You must agree to this policy to continue using this site.  Do you agree?';
 $string['policyagreement'] = 'Site Policy Agreement';
index 7bc2efd220d42b9d99f43976db2e8220c73eb833..01a50b53bf32036cff22a8c03735163d2b5fd531 100644 (file)
@@ -690,15 +690,20 @@ function close_window_button($name='closewindow', $return=false) {
  * Try and close the current window immediately using Javascript
  */
 function close_window($delay=0) {
-    echo '<script language="JavaScript" type="text/javascript">'."\n";
-    echo '<!--'."\n";
-    if ($delay) {
-        sleep($delay);
+?>
+<script type="text/javascript">
+<!--
+    function close_this_window() {
+        self.close();
     }
-    echo 'self.close();'."\n";
-    echo '-->'."\n";
-    echo '</script>'."\n";
-    exit;
+    setTimeout("close_this_window()", <?php echo $delay * 1000 ?>);
+-->
+</script>
+<noscript><center>
+<?php print_string('pleaseclose') ?>
+</center></noscript>
+<?php
+    die;
 }