[thelist] javascript force image to download?

phil phil at xlab.co.uk
Mon May 13 04:16:01 CDT 2002


I have a question regarding javascript -

I am building an image library which runs through a web browser from a
CD-ROM (yes, I know - not my idea..). I have built the interface and I'm
thinking of an easy way for people to click on an image and download it
to their desktop. The images are jpegs, so pointing to it through an
anchor tag opens it in new window instead of forcing the dowload.

In PHP I used to use the header() function, set the content-type to
"application/octet-stream" and open the file in the page - this would
force the browser to download the jpeg - but obviously from a CD I can't
use server-side technology.

Does anyone know of a way javascript could do a similar thing? perhaps
document.open() or similar?



More information about the thelist mailing list