473,473 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Download and Redirect... What am I missing ?

The script below allows me to link to a file and as the user clicks to
download, the 'File Download' windows appears as normal, and the user can
download...

The original page is then redirected to a new page..
This works, but it also opens a blank page..

How can this be chaged to stop the blank page from opening... ?

<script type="text/javascript">
function functionname(thefile){
document.location.href="somepage.html"
newwindow = window.open(thefile)
newwindow.close
}
</script>

<a href="#" onclick="functionname('filename.zip')">wqe</a>

Thanks
Jul 20 '05 #1
3 12375
James Kirk wrote:
The script below allows me to link to a file and as the user clicks to
download, the 'File Download' windows appears as normal, and the user can
download...
No, it does nothing of the sort. What it does is navigates the current page
to "somepage.html".
The original page is then redirected to a new page..
This works, but it also opens a blank page..

How can this be chaged to stop the blank page from opening... ?

<script type="text/javascript">
function functionname(thefile){
document.location.href="somepage.html"
The moment this line executes, "somepage.html" is loaded into the current
browser window and any lines after this point are discarded and not executed.
Also, it's "window.location.href". Most browsers do support
"document.location.href", but there's no guarantee it'll be supported in the
future.
newwindow = window.open(thefile)
newwindow.close
Neither of the above lines execute after you set window.location.href.
}
</script>

<a href="#" onclick="functionname('filename.zip')">wqe</a>

Thanks


That should be:

<a href="#" onclick="functionname('filename.zip');return false;">wqe</a>

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2
On Fri, 22 Aug 2003 22:14:07 GMT, Grant Wagner <gw*****@agricoreunited.com>
wrote:
James Kirk wrote:
The script below allows me to link to a file and as the user clicks to
download, the 'File Download' windows appears as normal, and the user can
download...


No, it does nothing of the sort. What it does is navigates the current page
to "somepage.html".
The original page is then redirected to a new page..
This works, but it also opens a blank page..

How can this be chaged to stop the blank page from opening... ?

<script type="text/javascript">
function functionname(thefile){
document.location.href="somepage.html"


The moment this line executes, "somepage.html" is loaded into the current
browser window and any lines after this point are discarded and not executed.
Also, it's "window.location.href". Most browsers do support
"document.location.href", but there's no guarantee it'll be supported in the
future.


Without the following line the download never starts !
newwindow = window.open(thefile)
newwindow.close


Neither of the above lines execute after you set window.location.href.
}
</script>

<a href="#" onclick="functionname('filename.zip')">wqe</a>

Thanks


That should be:

<a href="#" onclick="functionname('filename.zip');return false;">wqe</a>

Changing to this made no difference !

Any Ideas how I can start the download and redirect the current page to a
new one ?

Thanks
Jul 20 '05 #3
James Kirk wrote:
On Fri, 22 Aug 2003 22:14:07 GMT, Grant Wagner <gw*****@agricoreunited.com>
wrote:
James Kirk wrote:
The script below allows me to link to a file and as the user clicks to
download, the 'File Download' windows appears as normal, and the user can
download...


No, it does nothing of the sort. What it does is navigates the current page
to "somepage.html".
The original page is then redirected to a new page..
This works, but it also opens a blank page..

How can this be chaged to stop the blank page from opening... ?

<script type="text/javascript">
function functionname(thefile){
document.location.href="somepage.html"


The moment this line executes, "somepage.html" is loaded into the current
browser window and any lines after this point are discarded and not executed.
Also, it's "window.location.href". Most browsers do support
"document.location.href", but there's no guarantee it'll be supported in the
future.


Without the following line the download never starts !
newwindow = window.open(thefile)
newwindow.close


Neither of the above lines execute after you set window.location.href.
}
</script>

<a href="#" onclick="functionname('filename.zip')">wqe</a>

Thanks


That should be:

<a href="#" onclick="functionname('filename.zip');return false;">wqe</a>

Changing to this made no difference !

Any Ideas how I can start the download and redirect the current page to a
new one ?

Thanks


function functionName(theFile){
window.open(thefile, "_blank", "height=100,width=100");
window.location.href = "somepage.html";
}

It'll leave you with an open window you can't close programmatically, and it may
not actually download the file, the browser will do whatever it wants with the
MIME type provided. For example, if it's a .DOC or .XLS file, the browser is IE
and MS Office is installed, it'll try and open the document in the 100 x 100
window.

The only way to force the browser to download regardless of it's default handling
of a particular MIME type is to use server-side technology to change the
Content-Type and Content-Disposition headers before the document is sent.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #4

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

Similar topics

1
by: Damo | last post by:
Could someone please help me. I am a newbie at PHP. I downloaded formail.php Version 5.0 from Jacks scripts( http://www.dtheatre.com/scripts/ )and changed the required areas to my email address and...
11
by: Jim Willsher | last post by:
Hi all, PHP 4.2.2 on RedHat9 I have some files on my website for people to download, and I want to generate the file location "on the fly", so the URL is held in a database. I have a simple...
8
by: IGC | last post by:
I have a requirement to record in a database when a file is finished downloading to the end-user. Currently when a user clicks a download icon for a file it directs to an ASP page that records the...
12
by: Matt | last post by:
I want to write a ASP page to open/download a file In fileview.jsp, I have the file browse, and when user click submit button, fileview2.asp should open the file. fileview.asp ============...
2
by: Tom Youngquist | last post by:
I am trying to download a text file that my .NET page has just created based on entered parameters on the web page. Everything seems to work and the file is created. I am using the following code...
2
by: Jan Paul van de Berg | last post by:
I have a piece of software that people can download and a third party promoting that software. In order for them to be able to count the number of downloads, I have to put a tracking code on my...
6
ak1dnar
by: ak1dnar | last post by:
Hi, I am creating script to download some files using download dialog box.First time i tried to use ajax for this, but i failed. So i went through this way, By Using this function i am going to...
9
by: Matt Nunnally | last post by:
I have a form which allows the user to download a simple text file. They click on the download button and it brings up the "Save As" dialog. Once they save the file, I want them to be redirected to...
6
by: vstud70 | last post by:
Dear friends, I have a website that sells software. In my download page I have a "download" button that once the user clicks it open the windows wizard to /download/save/cancel the software. So...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.