开发者

refresh page after form download submit

开发者 https://www.devze.com 2022-12-22 19:38 出处:网络
I have a form that as an action returns a download. The pro开发者_如何转开发blem is that the page will pop-out the download, and you can save it, but it will not allow another form submit.

I have a form that as an action returns a download. The pro开发者_如何转开发blem is that the page will pop-out the download, and you can save it, but it will not allow another form submit.

i was thinking of doing a page refresh after the submit. But i cant figure out how to do that and not stop the download. Do you have any ideas.

Thanks


Make the initial form POST to an action which returns the same view along with some javascript that triggers the download. Also provide a "Your download should start shortly. Otherwise, click here"-link.

Have a look at

Auto start file download after form submission


This seams to be a bug in Chrome. The solution i got from here was to open a window before submit and put the target of the form in that window.

    function submitForm() {
//next line is the FIX
      window.open('','google');
      form = document.getElementById('myform');
      form.action = "http://www.google.com/search";
      form.target = 'google';
      form.submit();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消