Jump to content

initiate a file download using javascript


c_shelswell

Recommended Posts

Hi I need to start a file downloading using javascript. I had been using php's header but i'm using ajax to collect a users email and it doesn't appear to work anymore. So i was hoping after my page had been called succesfully i could use javascript to start the download?

 

I've tried window.open() which works fine but the firefox pop up stopper blocks it first is there a way to get round this?

 

Cheers

You can't.  You must load another window to push the download to the user.  Your best bet is to either open a DIV that has a link to the file that the user can right click and download or use a PHP redirect to a new page.

 

Keep in mind that JS can't call to the server to get the file, so you can't really expect it to be able to offer the file up.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.