I have command button while clicking the button it will redirect to VF page where it will renderas data as excel also it will open a site.Once the excel download is completed,the window needs to be closed.
VF Page
<apex:commandlink id="export" action="{!export}" onclick="redirect();" rerender="null" style="display: none;" >
<apex:commandButton style="background:#0065d3; border-radius: 10px; width: 300px; font-weight: bold;float: right; color: white; height: 40px;" value="Exporting" oncomplete = "testFun();return false;"/> </apex:commandlink>
function testFun() {
alert('Inside');
window.close();
}
function redirect() {
$("#confirmModal").hide();
console.log('redirecttttttttttttt');
window.open("{!$Site.BaseUrl}" + "{!successSite}", "_blank");
}
apex
public PageReference export() {
string urlString;
urlString = System.URL.getSalesforceBaseURL().toExternalForm()+'/apex/ExporttoExcel';
PageReference retURL = new PageReference(urlString);
retURL.getParameters().put('query',query);
retURL.setRedirect(true);
return retURL;
}
Here,before downloading the excel the window gets closed.Without using setTimeout function how can i close the current window once excel download completed.Please help me out !!