Tabs remain when downloading Excel (Edge browser only)

bonsai
Mega Sage

When the following process is executed as a UI action, an Excel file created on 4/16/2025 will be downloaded.

When executed in the Chrome browser, the download tab closes, but for some reason it remains open in Edge...

It doesn't seem like there's an error, but does anyone know the cause?

 

※When clicked "prb_test();"

function prb_test() {
    top.window.open('/problem_list.do?EXCEL&sysparm_fields=number&sysparm_query=sys_created_on=2025-04-16');
}
1 ACCEPTED SOLUTION

@bonsai 

I don't think it's because of the sysparm_query as it's the same in both the browsers.

It's the way how each browser handles the download

You can verify it in firefox if required.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

bonsai
Mega Sage

When you run the process in Edge, two tabs will open.
One will close and the other will remain.

When you run the process in Chrome, only one tab will open.
The one open tab will close.

Ankur Bawiskar
Tera Patron
Tera Patron

@bonsai 

it's because how browser handles the window.open method

try this so that it works in edge as well

function prb_test() {
    var downloadWindow = top.window.open('/problem_list.do?EXCEL&sysparm_fields=number&sysparm_query=sys_created_on=2025-04-16');
    setTimeout(function() {
        downloadWindow.close();
    }, 3000); // Adjust the delay as needed
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you for your answer!
I was also thinking of closing the tab with a timeout!

However, what bothers me the most is that for some reason the tab closes properly when I use the following code...
I'd like to know the cause, not a solution.

 

 

function prb_test() {
    top.window.open('/problem_list.do?EXCEL&sysparm_fields=number');
}

 

I think it's because of "&sysparm_query=sys_created_on=2025-04-16", but I don't know why the tab won't close...

@bonsai 

I don't think it's because of the sysparm_query as it's the same in both the browsers.

It's the way how each browser handles the download

You can verify it in firefox if required.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader