Refresh/navigate current page while opening/downloading file in new tab/window

后端 未结 2 1901
挽巷
挽巷 2020-11-30 15:11

I have a button which opens a new tab with a generated pdf-file. However, after I click on the button, I want to navigate to another page.

That means, after clicki

2条回答
  •  既然无缘
    2020-11-30 15:58

    As BalusC said, Refresh/navigate current page and opening downloading file are two different responses, there must be two resquests. I encountered a similar problem. I solved it with jsf ajax successfully.

    Here's part of my code:

    XHTML:

    
    
    
    
    

    Javascript:

    function checkCallBack(data) {
        var ajaxStatus = data.status;
        switch (ajaxStatus) {
        case "begin":
            break;
        case "complete":
            break;
        case "success":
            document.getElementById('download-form:download-button2').click();
            break;
        }
    }
    

    download-button renders a message area on page and download-button2 triggers a download method. they are two different requests. When the first request completed, the second request will be triggered.

提交回复
热议问题