http://stackoverflow.com/questions/11620698/how-to-trigger-a-file-download-when-clicking-an-html-button-or-javascript
http://webitect.net/design/20-effective-download-buttons-plus-tips-and-examples/
<form method="get" action="file.doc">
<button type="submit">Download!</button>
</form>
$("#fileRequest").click(function() {
// // hope the server sets Content-Disposition: attachment!
window.location = 'file.doc';
});
<a download='file'>Download</a>
<a href="file.doc" class="button" style="text-decoration:none">
Download!
</a>
<a href="http://www.example.com/folder1/file.doc">Download</a>
<input type="button" value="Download Now!" onclick="window.location = 'file.doc';">
<button type="submit" onclick="window.open('file.doc')">Download!</button>
function Download(){
window.open('file.doc');
}
<a href="file.doc">Download!</a>
<input type="button" value="Download!">
<button>Download!</button>
<form method="get" action="file.doc">
<button type="submit">Download!</button>
</form>
$("#fileRequest").click(function() {
// // hope the server sets Content-Disposition: attachment!
window.location = 'file.doc';
});
<a download='file'>Download</a>
<a href="file.doc" class="button">
Download!
</a>
.button
{
/*Make your button look cool.*/
}
<input type="button" value="Download Now!" onclick="window.location = 'file.doc';">
<button type="submit" onclick="window.open('file.doc')">Download!</button>
function Download(){
window.open('file.doc');
}
沒有留言:
張貼留言