Download File Using Javascript/jQuery

前端 未结 28 2977
悲&欢浪女
悲&欢浪女 2020-11-21 05:11

I have a very similar requirement specified here.

I need to have the user\'s browser start a download manually when $(\'a#someID\').click();

But

28条回答
  •  猫巷女王i
    2020-11-21 05:43

    There are so many little things that can happen when trying to download a file. The inconsistency between browsers alone is a nightmare. I ended up using this great little library. https://github.com/rndme/download

    Nice thing about it is that its flexible for not only urls but for client side data you want to download.

    1. text string
    2. text dataURL
    3. text blob
    4. text arrays
    5. html string
    6. html blob
    7. ajax callback
    8. binary files

提交回复
热议问题