Onclick "File Save As" - How do i do this?

Lets say i have two links to same file called “cat.avi”

<a href=“http://site.com/cat.avi”>Play Movie</a>

and

<a href=“http://site.com/cat.avi”>Download Movie</a>

when the user clicks the second link, how can i make the file to be prompted for a download, instead of opening the cat.avi file with the windows media player or what ever?

try this (IE Only I beleive)

<button onclick="javascript:document.execCommand('SaveAs','1','fileName.txt')">Click to save</Button>

Reference

Hope this helps. cb

Thanks for ur suggestion. It works great for files on the same folder as the script but the thing is, i create url of the files dynamically using php

so an example url will be like this

<td height=“20”><a href=“$url”>Download File</a></td>

as you can see, your code is like this

<td height=“20” width=“100%”><button onclick=“javascript:document.execCommand(‘SaveAs’,‘1’,‘$url’)”>Click to save</Button>
</td>

and when i try it, it dun work :frowning: