Download and Redirect with One Click
Would you like to provide a download link for your site
visitors that begins the download and then sends the browser
to a different web page?
If you've never thought about doing such a thing, here are
some one-click ideas:
-
Provide a download and a web page of installation
instructions.
-
Present a web page with information about a pro
version of the the free download.
-
Provide a download of a PDF document, then a web
page with an opportunity to subscribe for more
of the same kind of information. Paul Myers is
providing a "Resources for Starting and Running
Your Online Business" download in this way.
(Paul provided the idea for this one-click method.)
Click http://tbrx.com/directory/download.html to see
it in action (or /artmyerspdf
for more info about the PDF document, first).
It is similar to clicking on a link that takes the visitor
to a page at another URL, a normal link. The difference is
that a download starts between the time the link is clicked
and the time the visitor is taken to a different web page.
How this one-click method works:
-
The download link has two attributes, an "href"
and an "onclick."
The "href" contains the URL of the downloadable
file.
The "onclick" contains that name of a JavaScript
function that sets up a delayed redirect to a
different web page URL.
-
When the download link is clicked, the delayed
redirect is set up and the download commences.
At the end of the delay period, the browser is
redirected -- whether or not the download has
completed.
Here is the JavaScript:
The destination web page URL and the number of seconds to
delay can both be customized. In the above JavaScript, the
URL is http://FlowTo.info/ and the delay is 4 seconds
(specified as 4000 milliseconds).
Notice that the function returns a value of true. This
allows the download to commence even with a redirect
delay having been set.
Here is the HTML link:
If using the JavaScript and HTML exactly as provided above,
the redirect to http://FlowTo.info/ is set up when the link
is clicked. The download of /test.zip
then commences. Four seconds after the link was clicked,
the browser is redirected to http://FlowTo.info/.
The JavaScript can be anywhere on the page, above or below
the link or in the HEAD area.
Now, you can provide your visitors with a download *and*
open a web page with more information.
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©2005 Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.