472,977 Members | 2,070 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,977 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 1798
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?...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.