Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Meta Tag Refresh Isn't Working

Status
Not open for further replies.

mtorbin

Technical User
Nov 5, 2002
369
US
Here's the body of the .cgi file:

Code:
#!/usr/bin/perl -w

use CGI qw/:standard/;
use CGI::Cookie;
use CGI::Carp qw(fatalsToBrowser);
use perlLib;

%cookies = fetch CGI::Cookie;
my $emailCookie = $cookies{'peiEmail'}->value;
my $ipCookie = $cookies{'peiIP'}->value;

my $fileName = substr $ENV{"QUERY_STRING"},32;  ## not 9

my $fileLoc  = '[URL unfurl="true"]http://rhlwebsvr/ftpfiles/'[/URL] . $fileName;
   $fileName =~ s/\%20/ /gi unless (-e $fileLoc);

my $logFileName = $fileName; 
 
my($localDate,$localTime) = createDateStamp();
my $timeStamp = "$localDate $localTime";

$logEntry = '<tr align=left valign=top><td><a href=mailto:' . $emailCookie . '>' . $emailCookie . '</a></td><td>' . $ipCookie . '</td><td>' . $timeStamp . '</td><td>' . $logFileName . '</td></tr>' . "\n";

open (LOG, ">>ftpLog.txt") or die "file cannot be opened.";
flock (LOG, 2);
print LOG "$logEntry";
close (LOG);

print <<"HTML code";
Content-type: text/html\n\n
<html>
<head>
<meta http-equiv="refresh" content="5; URL=http://rhlwebsvr/ftpFrame.html">
<title>File Download In Progress</title>
<link href=../ftpStyle.css rel=stylesheet type=text/css>
<script src=../jsLibFTP.js></script>
</head>
HTML code

print qq(<body onLoad="delayDownload('$fileName')">);

print <<"HTML code";
<br>
<br>
<table width=300 border=0 align=center cellpadding=0 cellspacing=0>
<tr align=center valign=top>
<td width=19 height=20><img src=../images/box_blue_corner_tl.gif width=19 height=20></td>
<td background=../images/box_blue_side_t.gif><img src=../images/box_blue_side_t.gif width=2 height=20></td>
<td width=19 height=20><img src=../images/box_blue_corner_tr.gif width=19 height=20></td>
</tr>
<tr align=center valign=top>
<td background=../images/box_blue_side_l.gif><img src=../images/box_blue_side_l.gif width=19 height=2></td>
<td bgcolor=#6699CC>
<h5>Your file is currently downloading...</h5>
<img src=../images/progressBar.gif width=225 height=14>
<br>
<br>
If your file does not download,<br>
HTML code

print "please click <a href=" . $fileLoc . ">HERE</a>"; # $fileLoc will be supplied by the form.

print <<"HTML code";
<br>
<br>
</td>
<td background=../images/box_blue_side_r.gif><img src=../images/box_blue_side_r.gif width=19 height=2></td>
</tr>
<tr align=center valign=top>
<td width=19 height=20><img src=../images/box_blue_corner_bl.gif width=19 height=20></td>
<td background=../images/box_blue_side_b.gif><img src=../images/box_blue_side_b.gif width=2 height=20></td>
<td width=19 height=20><img src=../images/box_blue_corner_br.gif width=19 height=20></td>
</tr>
</table>
<br>
<div align=center><strong>Version 2.0</strong></div>
<br>
<br>
</body>
</html>
HTML code

Here are the two functions in question (JavaScript):
Code:
function delayDownload(fileName) {
    fullURL = "[URL unfurl="true"]http://rhlwebsvr/ftpfiles/"[/URL] + fileName;
    window.setTimeout("processDownload(fullURL)", 2000);
}


function processDownload(fullURL) {
    window.location.href = fullURL;
}

Everything downloads fine and I get no JS errors, but the page never refreshes. What am I missing? Control is switched to the browser to download the file, but then should be switched back to the page, right?

-MT
 
Hello mtorbin!
Did you have any luck solving this issue as I have the same problem - URL will not open in the browser window using refresh. Any help much appreciated.
Thanks
 
Control is switched to the browser to download the file, but then should be switched back to the page, right?

In my experience on Internet Explorer, when you click a link (or otherwise begin loading a new URL), the current page is "stopped" -- i.e. any images that haven't loaded stop trying to load, animations stop, embedded sounds stop, and certain methods of automatic redirection stop as well (i.e. meta refresh)

So if your page is linking to the download in 2 seconds, that will stop the page and cause the meta tag to stop before finishing its 5 second delay.

You can change this with your JavaScript. Since the user seems to depend on the JS for the automatic downloading of the file, you can just set another timeout.

Code:
function delayDownload(fileName) {
    fullURL = "[URL unfurl="true"]http://rhlwebsvr/ftpfiles/"[/URL] + fileName;
    window.setTimeout("processDownload(fullURL)", 2000);
}


function processDownload(fullURL) {
    window.location.href = fullURL;
    [COLOR=red]window.setTimeout("gotoFtpFrame()", 3000);[/color]
}

[COLOR=red]function gotoFtpFrame() {
    window.location.href = "[URL unfurl="true"]http://rhlwebsvr/ftpfiles/ftpFrame.html";[/URL]
}[/color]

An alternative (if you want to keep the meta tag method for non-JavaScript-enabled users), is to open the download file in a new window, so that it doesn't stop the current window.

Code:
function delayDownload(fileName) {
    fullURL = "[URL unfurl="true"]http://rhlwebsvr/ftpfiles/"[/URL] + fileName;
    window.setTimeout("processDownload(fullURL)", 2000);
}


function processDownload(fullURL) {
    [COLOR=red]window.open (fullURL);[/color]
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top