Make the close_window function better. Merged from MOODLE_17_STABLE.

This commit is contained in:
tjhunt 2006-10-31 11:59:54 +00:00
parent d84d379e97
commit dfa924cc99
2 changed files with 14 additions and 8 deletions

View 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;
}