Loading page

J

John

Hello, I have a cgi script that takes ~20sec to run. I'd like to have
a page appear when the page was submitted that told the user that
their results page would load in ~20 secs ... Is there a way of doing
this using javascript?

Thanks,

John
 
B

Bart Van der Donck

John said:
Hello, I have a cgi script that takes ~20sec to run. I'd like to have
a page appear when the page was submitted that told the user that
their results page would load in ~20 secs ... Is there a way of doing
this using javascript?

--------------------------------------------------------
START CODE
--------------------------------------------------------

#!/usr/bin/perl
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
$|++;
print qq{Content-Type: text/html; charset=iso-8859-1

<html>
<head>
<title>My cool web page</title>
<script type="text/javascript">
var counter = 0;
var txt = 'Please wait 10 seconds... '
function doCount() {
++ counter;
if (counter <= 10) {
document.getElementById('nr').innerHTML = txt + counter;
setTimeout('doCount()', 1000);
}
else {
document.getElementById('nr').innerHTML = '';
document.getElementById('nr').style.visibility = 'hidden';
document.getElementById('nr').style.display = 'none';
document.getElementById('cgi').style.visibility = 'visible';
}
}
</script>
</head>
<body>
<div id="nr"></div>
<script type="text/javascript">
doCount();
</script>
<div id="cgi" style="visibility:hidden;">
};
sleep 10;
print ' HTML output CGI script goes here';
print qq{
</div>
</body>
</html>
};

__END__

--------------------------------------------------------
END CODE
--------------------------------------------------------

I've put a demo here:
http://www.dotinternet.be/temp/demo.cgi
Please view the page's source during those 10 seconds, and keep an eye
on the browser's progress bar.

Hope this helps,
 
J

John

Cheers mate, I have it working now :) Thing that I was getting wrong
was missing the line

Could you tell what this means? And why it is needed.

Thanks again,

John
 
B

Bart Van der Donck

John said:
Cheers mate, I have it working now :) Thing that I was getting
wrong was missing the line


Could you tell what this means? And why it is needed.

The pre-declared variable $OUTPUT_AUTOFLUSH, or $| in short,
determines whether the stream to the current selected output channel
is buffered or not. The output stream is unbuffered by assigning it a
value other than zero.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,150
Messages
2,570,853
Members
47,394
Latest member
Olekdev

Latest Threads

Top