IE11 - Avoid Window Close Confirmation Message

My requirement is that when I click to download a file, a new tab opens. If the file exists, it will start downloading, and if not, it should close a new tab and show an error message.

I used

window.close() 

and it works fine. In addition, IE11 asks for confirmation:

"The webpage you are viewing is trying to close a tab. Do you want to close this tab?"

this interrupts the functionality of the system, and the user does not know why this happened.

Any solution on this?
I outlined the whole scenario so that you can give a solution for any stage.

Thanks.

+5
source share
1 answer

I saw this warning when you try to use window.close() in the window that the user opens; This is a safety measure. You cannot close the window through the JavaScript that the user opens.

One way is to send a request to the servlet and return the file from the servlet. Let me know if this does not work for you.

0
source

All Articles