Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

location.href and close window 1

Status
Not open for further replies.

bigfoot

Programmer
May 4, 1999
1,779
US
I placed a button on my page with this code:

onclick=location.href='/myfolder/myfile.zip'

This will show the download window for the file when I press the button.

OK, so now I want to close the popup window.

onclick=window.close()

Yes, now I want to show the downloaded file window, and then close the window.

onclick=location.href='/myfolder/myfile.zip';window.close();

NO, this does not work. It only closes the window. Why?

Pleeeeease tell me. I am a VB programmer, not a JS programmer.

 
It's closing the window because you're asking it to. It processes both commands very quickly - calls the page and then closes the window.

Please explain a little more what you're trying to do...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
I have a main window, that when the user clicks on a button, it calls a small popup window with "Please Wait", in it.

Then when the file is built in the background, it replaces the contents of the popup window with a button or link, that when the user clicks on it, it

A. Brings up the standard browser's download box to D?L the file

B. Closes the popup window, as It is not needed any longer.

Thanks
 
Hmm - you'd usually put the code in the page you call last, but since that's a download, I'm not sure it's possible to automatically close the popup. I know that I've used email programs that couldn't close the attachment download window. Perhaps you could close it in say - 5 seconds...

<script>
function getZip(zipLink){
location.href = zipLink
setTimeout(&quot;closer()&quot;, 5000)
}

function closer(){
self.close()
}
</script>

<input type=button onClick=&quot;getZip('/myfolder/myfile.zip')&quot; value=&quot;Download&quot;>


It's worth a try - don't know if it'll work or not...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
mwolf00, you are the best! You've hit the motherload here. It works great!

I love it.


Thanks so much. And you get a star. :-D [medal][thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top