How to download a file via js?

Good day, there is a variable which stores a link to the file:
when you output via the console
the result is the full url in the format:
but when you run
location.href = url_download;
the transition occurs on the link

What's the problem, what am I doing wrong, please tell me
March 23rd 20 at 19:03
2 answers
March 23rd 20 at 19:05
And if you do so...?
window.location = url_download;
The result is no different - Kaitlin.Langworth commented on March 23rd 20 at 19:08
And url_download exactly is https:// at the beginning of the line?
And then JS acts as if it there there.
Make console.log(url_download.substr(0, 8));to check. - arturo_Emmerich commented on March 23rd 20 at 19:11
March 23rd 20 at 19:07
what about this

var download = document.createElement("a");
download.href = "" ; = "file.doc"; = "none"; = "download";
download = undefined;
and why


In General, why not simply
let link = document.createElement('a');
 link.href = response; = name;;

, for example? - orville.Daniel53 commented on March 23rd 20 at 19:10

Find more questions by tags JavaScript