It works! But then there's a tiny window that doesn't close. Is there anyway to get this window to close from the "parent?" I'll need to have this working for about 16 links on one page...
I'm assuming you know this doesn't really hide the file location - anyone could find it in your source code.
Yes, you can close windows from parents (or indeed from anywhere) but you need to set up your pop-up windows properly to do this - i.e. with names). Better to call a function from your onclick and open the window from there, giving it a name. Then, via that name, you can close it, write to it, reposition it, whatever. Look up any pop-up window script online and you'll see this - the name is one of the arguments you pass to window.open().
I'd be inclined to do what you're doing with a hidden iframe - saves the ugliness of an appearing then disappearing pop-up.
Yes, I totally realize it's be revealed in the source - not needing a super secure solution here. Hidden iframe! That sounds great! How wold I do that?
Just have an iframe with display:none set then literally just point your link at it (in the target="" attribute). Then the download prompt will come up (depending on the filetype of the downloaded file) and look as though it came straight from the main page.
The browser doesn't care that it's hidden - as far as it's concerned, it's a valid HTTP gateway and has all the loading capability and DOM structure of the main page. Glad you got it sorted.
I didn't suggest anything which would make the download begin onload as opposed to on a link click. As I said, you simply need to target your download link to the iframe. So for example:
Code:
<a href="someFile.zip" target="ifr">Click here to download</a>
<iframe name="ifr" width="1" height="1"></iframe>
I want a link like <a href="javascript:void(0) ...> so the file (ie someFile.zip) isn't revealed in the status menu (which is why I'd rather not link to the file in the first place.) I was thinking you meant for the link onclick to reveal the hidden iframe, (which would have src="someFile.zip) hence the file would download.
What I'm experiencing is that the file downloads on page load, which I don't want. (I want the user to have to click the link.
Does this make sense? Is there a practical way to do this? Iframe or not, all I basically need is a way to download a file via javascript....
I'm so confused! You just posted my message back to me. It looks correct, like my message. I don't understand what's wrong. Look in the source code, it's there! Arrghhhh!
Bookmarks