Download File Using Javascript/jQuery

前端 未结 28 2878
悲&欢浪女
悲&欢浪女 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条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-21 05:54

    Excelent solution from Corbacho, I just adapted to get rid o the var

    function downloadURL(url) {
        if( $('#idown').length ){
            $('#idown').attr('src',url);
        }else{
            $('