Users fill out a form. With a valid form, they click to download a file. I would like to be able to redirect them to another page (e.g., page2.html
) AND initiate a download.
I can't initiate download on page2.html
because most browsers will flag security warnings if a download link isn't directly clicked on.
How is something like this accomplished using javascript or jquery? Obviously the following doesn't work but it's meant for illustrative purposes:
document.getElementById("foo").onclick = function(){
window.location = "/download.exe";
window.location = "/page2.html";
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…