faqts : Computers1 : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

40 of 50 people (80%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How do I write an "onclick" script that will open the "Save as" window to save a linked file?

Apr 25th, 2002 05:36
Colin Fraser, Sue Steyh,


The problem I see is that you are attempting to take control of a
browser function, and that is not always possible. 
For Netscape browsers it is unlikely that you can do so at the moment,
however for IE I suspect that there would be some call to a dialogue box
that will do it, however, looking for it could be time consuming, you
may want to look in this site first.. 
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtmlrefs.asp
OK, it is the Dark Side, but I know of no other place to look for
information on IE.. They may also suggest some other way of doing what
you want, but it will probably not work anyway..
Sorry, but this is the best advice I have at the moment, hopefully
someone else may have a better answer, but dont wait for it..
===========================================
To follow this up, you may try 
function saveFile (fname)
{
	document.execCommand('SaveAs',null,fname)
}
You can use a button 
<input type="button" value="Save" onClick="saveFile('thispage.htm');">
or text
<a href="javascript:null()" onClick="saveFile('thispage.htm');">Save
File</a>
Good luck..