faqts : Computers : Programming : Languages : JavaScript

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

35 of 62 people (56%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Making a Link Default to "Save Target As" with Left Click

Apr 8th, 2008 00:02
ha mo, Colin Fraser, ThomK,


The problem I see is that you are attempting to take control of a
browser function, and that is not always possible. However, a lot of 
information can be found here: 
http://msdn.microsoft.com/library/default.asp?
url=/workshop/author/dhtml/dhtml_node_entry.asp
OK, it is the Dark Side and DHTML rather than pure Javascript, but they 
may suggest some other way of doing what you want.
You may want to 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>
This should work.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com