472,958 Members | 2,149 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,958 software developers and data experts.

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 12344
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
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
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
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...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
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 :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
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...
2
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.