Created
February 25, 2013 04:58
-
-
Save ebinnion/5027845 to your computer and use it in GitHub Desktop.
Download and Redirect in jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".downloadLink").click( | |
function(e) { | |
e.preventDefault(); | |
//open download link in new page | |
window.open( $(this).attr("href") ); | |
//redirect current page to success page | |
window.location="www.example.com/success.html"; | |
window.focus(); | |
} | |
); |
Hello @ragineeguptta - It's been 9 years since I wrote this Gist, so I don't recall what exactly I was trying to do here. My best guess after reading this is that I was wanting to:
- Store a reference to the file to be downloaded in the
href
of the link - Open a new tab to download that file
- Redirect the current window to a success page
- Then refocus the current window, probably due to opening the file in a new tab
But, it's unclear to me.
Do you have something in a shareable state that I could look at?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What will the script id download file not open in another page only page redirect after click and file auto download?