'downloadWindow = window.open(fileUrl); auto/force download/save file

I have following line of code :

downloadWindow = window.open(fileUrl);

How to make window.open(fileUrl); can automatically save/download file

I tried following

downloadWindow = window.open(fileUrl, '_self'); // do not work
downloadWindow = window.open(fileUrl, 'download'); // do not work to
downloadWindow = window.location(fileUrl, 'download'); // do not work
downloadWindow = window.location.href(fileUrl); // do not work

not work can auto save/download file,

I can not auto/force/directly save/download file without a popup



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source