Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Download and Redirect... What am I missing ?

Reply
Thread Tools

Download and Redirect... What am I missing ?

 
 
James Kirk
Guest
Posts: n/a
 
      08-22-2003
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
 
Reply With Quote
 
 
 
 
Grant Wagner
Guest
Posts: n/a
 
      08-22-2003
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 <(E-Mail Removed)>

* 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


 
Reply With Quote
 
 
 
 
James Kirk
Guest
Posts: n/a
 
      08-23-2003
On Fri, 22 Aug 2003 22:14:07 GMT, Grant Wagner <(E-Mail Removed)>
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
 
Reply With Quote
 
Grant Wagner
Guest
Posts: n/a
 
      08-25-2003
James Kirk wrote:

> On Fri, 22 Aug 2003 22:14:07 GMT, Grant Wagner <(E-Mail Removed)>
> 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 <(E-Mail Removed)>

* 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setup file missing from download RichM Windows 64bit 10 12-12-2007 11:31 AM
Crystal Reports - Visual Basic UFL that implements this function is missing (or U2lcom.dll is missing) Les Caudle ASP .Net 3 09-03-2007 02:27 AM
Re: missing feature classes and missing fields Gary Herron Python 2 07-04-2006 10:29 PM
I am missing some CABS for Win 98 Is there a place I can download them? Fred McDonald Computer Support 5 09-28-2003 02:21 PM



Advertisments