Link to home
Start Free TrialLog in
Avatar of Pigdogmonster
Pigdogmonster

asked on

left click to download

Hi, Thanks for looking at my question!

Does anyone know a simple script that allow the user to click a link or button with the left mouse that brings up the Download dialog box?

Normally you have to right click and go to 'Save As'.

Many thanks

PDM
Avatar of Anindya_M
Anindya_M

This works in IE

function f()
{
  document.execCommand("SaveAs",true,"C:\\My Documents\\Saved Content.html");
}

f should be called on the onClick event handler for a button, etc.
Avatar of Pigdogmonster

ASKER

thanks Anindya,

Could you give me an example say with an Image

i.e.

<img src="Download.gif" border="0" onclick="">

Thanks

PDM
<html>
<script>
function f()
{
  document.execCommand("SaveAs",true,"C:\\My Documents\\Saved Content.html");
}
</script>
<body>
<img src="download.gif" onClick="f()">
</body>
</html>
thanks Anindya,

How can I make the filenname a variable?

As I will be using within a loop in ASP.
Dont worry!

I found it...

<a href="javascript:void(0);"
 onclick="document.execCommand('SaveAs',true,'file.html');"
 >Save this page</a>


Thanks again!

PDM
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial