site Search:


 
    All Forums Hot Topics Gallery






how-to block ads


 
Search Topic:
Uniqs:
140595
Share Topic
Posting?
Post a:
Post a:
Links: ·How To Get Noticed ·Web Monks FAQ ·Webhosting FAQ ·Posting Code ·How To Post ·Webhosting forum
AuthorAll Replies


franzcatch
Mad A
Premium
join:2003-06-24
Saint Louis, MO

1 edit

Opening a file download dialog from a JavaScript function.

I am developing a webpage and want my users to be able to download a file from me.

I know I can put a link on the page for the user to click like this:
<a href="download/VB6IP.zip">Download</a>  
 

However, I would like to launch the dialog from a JavaScript function.
Is there an easy way to accomplish this?

--
Insert wisdom here...

OZO
Premium
join:2003-01-17
kudos:2

Any reason why do not use good old way?
For security reasons users may have JavaScript turned off...



cowboyro

join:2000-10-11
Shelton, CT
Reviews:
·AT&T U-Verse

2 edits

reply to franzcatch

in the HEAD section:
<script type="text/javascipt">
function startDownload()
{
var url='http://server/folder/file.ext';  
window.open(url,'Download');
}
</script>
 
in BODY
<script type="text/javascipt">
setTimeout("startDownload()",5000); //starts download after 5 seconds
</script>
 

or if you have just 1 download location you can combine the 2 in the body:

<script type="text/javascipt">
setTimeout("window.open('http://server/folder/file.ext','Download')",5000); 
</script>
 

Edit: I wouldn't worry so much about the 0.01% that are paranoid and turn off javascript... But *do* provide a link in case a popup blocker kills the download.

Sunday, 19-May 07:08:59 Terms of Use & Privacy | feedback | contact | Hosting by nac.net - DSL,Hosting & Co-lo
over 13.5 years online © 1999-2013 dslreports.com.
Most commented news this week
Hot Topics