Information wasn't being printed on-screen before the javascript redirect
was kicking in. It was either a problem with the PHP flush() function or in a browsers handling of half output XHTML. Either way the fix was to include the delay in the javascript. Messages during a redirect should now be displayed correctly. Bug 3118. (SE)
This commit is contained in:
+14
-3
@@ -3704,6 +3704,7 @@ function redirect($url, $message='', $delay='0') {
|
||||
echo '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />';
|
||||
echo '<script type="text/javascript">'. "\n" .'<!--'. "\n". "location.replace('$url');". "\n". '//-->'. "\n". '</script>'; // To cope with Mozilla bug
|
||||
} else {
|
||||
|
||||
if (empty($delay)) {
|
||||
$delay = 3; // There's no point having a message with no delay
|
||||
}
|
||||
@@ -3712,9 +3713,19 @@ function redirect($url, $message='', $delay='0') {
|
||||
echo '<p>'. $message .'</p>';
|
||||
echo '<p>( <a href="'. $encodedurl .'">'. get_string('continue') .'</a> )</p>';
|
||||
echo '</center>';
|
||||
flush();
|
||||
sleep($delay);
|
||||
echo '<script type="text/javascript">'."\n".'<!--'."\nlocation.replace('$url');\n".'//-->'."\n".'</script>'; // To cope with Mozilla bug
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
|
||||
function redirect() {
|
||||
document.location.replace('<?php echo $url ?>');
|
||||
}
|
||||
setTimeout("redirect()", <?php echo ($delay * 1000) ?>);
|
||||
-->
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user