• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 266
  • Last Modified:

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
0
Pigdogmonster
Asked:
Pigdogmonster
  • 3
  • 2
1 Solution
 
Anindya_MCommented:
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.
0
 
PigdogmonsterAuthor Commented:
thanks Anindya,

Could you give me an example say with an Image

i.e.

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

Thanks

PDM
0
 
Anindya_MCommented:
<html>
<script>
function f()
{
  document.execCommand("SaveAs",true,"C:\\My Documents\\Saved Content.html");
}
</script>
<body>
<img src="download.gif" onClick="f()">
</body>
</html>
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
PigdogmonsterAuthor Commented:
thanks Anindya,

How can I make the filenname a variable?

As I will be using within a loop in ASP.
0
 
PigdogmonsterAuthor Commented:
Dont worry!

I found it...

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


Thanks again!

PDM
0
 
GranModCommented:
PAQed with points refunded (25)

GranMod
Community Support Moderator
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now