You can't. This is fundamental "user interface" 101. A programmer shouldn't attempt to force actions that are historically under user control. Also, what you're attempting violates the browser security model. Just imagine the havoc that would be caused if a web page could "silently download" anything as soon as you browse to it.
I understand you simply want the dialog to pop up, but it's still not allowed.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
It can't be done with HTML, CSS or JavaScript, the topics covered in this forum. What akadez is referring to are some possible techniques in ASP.NET, a server-side language. Daniweb has an ASP.NET forum, if you code in that language.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
Most of your visitors will have .zip files set to offer as download rather than process automatically so you could upload in that format. There is also code that can be put in the .htaccess file to force what you want if your site is running on an apache server.
felgall
Junior Poster in Training
50 posts since Aug 2004
Reputation Points: 13
Solved Threads: 1
I don't mind the question, but you're asking it in the wrong spot! Daniweb has a forum specifically for these types of issues: http://www.daniweb.com/techtalkforums/forum64.html
If you'll peruse that forum, I think you'll get the education you seek! If not, feel free to post a new thread there. No one will bite your head off; we try to be a friendly group.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
Wait wait wait ... what is being asked is a client-side technology, not server-side at all ... Anything that would interact directly with the web browser - such as opening a dialog menu, would have to be a client-side script.
Server side scripts can interact with files on the server, but you need something client side to interact with files or applications (in this case, the web browser) on the client side of things.
I think this could be accomplished in DHTML (although I'm not sure specifically how to go about it), can it not?
cscgal
The Queen of DaniWeb
19,432 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
Update, I searched the web and found out how to do it in JavaScript:
<a href="#" onclick="javascript:document.execCommand('SaveAs','1',null);">Link Here</a>
Replace null with a filename (if you use frames, or if you want clicking the link on one page to save another one).
cscgal
The Queen of DaniWeb
19,432 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
The code I provided will pop up with a message box when a link is clicked on. It is similar to those links that say "Click here to add this site to your Favorites / Bookmark list" ... only this one is a "Click here to download this page"
cscgal
The Queen of DaniWeb
19,432 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230
cscgal - the code you provided is IE only, and won't work with strict doctypes.
Bomba - spyware works by sneaking in a program that runs concurrently with or as an extension to the browser. It usually works by the user actually installing the spyware, through accepting a page that wants to install a "plug-in" of some sort. Then whenever the browser starts, the spyware starts. That topic really is best explored in the other forum, this one is to discuss client-side programming.
Original Poster - there is no way, as I explained, to code a button that downloads a file, in a completely client-side manner (aside from the IE-only activeX trick).
The proper way to do this is to stream back the proper mime-type. That's server configuration and server-side programming, not client-side. If the user has his browser configured to support that mime-type with a helper application (think "Acrobat Reader" or "Flash"), the stream will be passed to that application. Otherwise, the user will be asked what they want to do with the stream being served. That's the way the web works.
tgreer
Made Her Cry
2,118 posts since Dec 2004
Reputation Points: 227
Solved Threads: 37
I'm sorry folks! I misread the question. Ignore me :) What I had THOUGHT you wanted was a link that duplicated the Internet Explorer function of selecting "Save As" from the File menu. I completely didn't notice the word "target" for some reason. I shouldn't post too early in the morning anymore.
cscgal
The Queen of DaniWeb
19,432 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 230