473,385 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

help with the following code (open a download dialogue and then redirect to a new page)

So, I'm doing the following in a php script so that I can fire a
download dialogue AND redirect the page (after clicking submit in a
form). I'm doing it this way because of the problem with headers and
such and server-side vs client-side issues:

$dir = "somedir";
$file = "somefile";

print("
<script language=\"JavaScript\">
<!--
my_window =
window.open('get.php?dir=packages$dir&file=$file', 'Downloading','width=1,height=1,resize=no');
window.location.href = '$redirpage';
setTimeout('window.close()', 5000);
//-->
</script>");

Everything works here EXCEPT for the closing of the d**n empty window
that is opened. My get.php fires to open a new dialogue to download
the file I want, the page I was on gets redirected to $redirpage, but
the empty window doesn't close. If I DON'T use setTimeout and just do
the following:

print("
<script language=\"JavaScript\">
<!--
my_window =
window.open('get.php?dir=packages$dir&file=$file', 'Downloading','width=1,height=1,resize=no');
window.location.href = '$redirpage';
my_window.close();
//-->
</script>");

then the window closes but too fast for the get.php to pop up the
download dialogue (hence my need to delay the close of the window a
bit). I've tried using setTimeout('my_window.close()', 5000); but the
empty window never closes. This is driving me nuts as it appears it
should be fairly straight forward. Any assistance is greatly
appreciated. (BTW, I'm fairly novice at this so any better ideas on how
to do what I'm trying to do is also greatly appreciated).

Thanks.

Kevin

Aug 30 '05 #1
2 1817
kevinm3574 schrieb:
So, I'm doing the following in a php script so that I can fire a
download dialogue AND redirect the page (after clicking submit in a
form). I'm doing it this way because of the problem with headers and
such and server-side vs client-side issues:

$dir = "somedir";
$file = "somefile";

print("
<script language=\"JavaScript\">
<!--
my_window =
window.open('get.php?dir=packages$dir&file=$file', 'Downloading','width=1,height=1,resize=no');
window.location.href = '$redirpage';
setTimeout('window.close()', 5000);
//-->
</script>");


in this variant, you would close the main-window, not the popup. You want to
close my_window, not this window. But the Problem is an other: Your're leaving
the page, that has the information about the popup-window and setTimeout (AFAIK)
don't survives a location-change. So something like this should work:

my_window.setTimeout('self.close()', 5000);

This way, you're applying the Timeout to the popup-Window.

Greetings,

Martin
Aug 30 '05 #2
Martin,

Thanks!!! That works great. I appreciate your responding.

Kevin

Aug 31 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: pargat singh | last post by:
Hi Everyone, THIS IS SECOND TIME I AM POSTING MY PROBLEM.I have a log file like 123.log and i want to display this log in browser.In ASP page at top i have following. <%Response.Buffer =...
2
by: Bobby | last post by:
Hello everyone I have a question. The school I am working for is in the beginning process of having a webpage that will direct students to download there homework and be able to view there info...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
6
by: No_Excuses | last post by:
All, I am interested in reading the text of a web page and parsing it. After searching on this newgroup I decided to use the following: ******************************* START OF CODE...
7
by: Joe | last post by:
Hi, I’m new to asp.net. I want to create an asp.net page that allows user to edit the data. I have pasted my code below. I am able to display the data in a datagrid. At the bottom of the page...
3
by: Chuck Renner | last post by:
Please help! This MIGHT even be a bug in PHP! I'll provide version numbers and site specific information (browser, OS, and kernel versions) if others cannot reproduce this problem. I'm...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.