I redirected to download page (I used window.location() or window.location.href() or replace()), but after download happens it should again come back to same page. I tried using setTimeout, but in vain. Another thing I dont have a chance to write redirect in download.php. Is there any solution for this requirement. Thanks in advance... Here is my sample code...
Can't be done. Your download page isn't acting like a web-page, it's acting like a file. When downloading a file - the headers get sent, then everything else afterward is considered file data. You can't put javascript before the file, because outputing javascript will send headers - breaking your download. You can't put a redirect after the file data because headers (ie: redirect headers) can't be sent after output has started.
If you have a webpage that has a link to a download, then when the user clicks the link a dialog should appear asking them what to do with it. Regardless of what they choose, the dialog will eventually go away, the browser will start downloading the file, and the user remains on the page they were on when they clicked the link. So I'm not really sure how a user's browser can navigate from a webpage to the URL of a file, if that file is being force downloaded.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.