General discussion

Locked

download Word document with JavaScript

By zabronm ·
I want to enable my clients to download a word application form from my website. I want to use JavaScript or simple html (not cgi). Is this possiblea nd if it is, how? I want the download dialog box to appear so that users chose to open or save it locally. Please help

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

server-side

by Jay Eckles In reply to download Word document wi ...

You're going to have to do something on the server side if you want to attempt to make a download dialog box appear. One thing you could do is configure your webserver so that the mime type of any document ending in .doc is application/octet-stream. If you use a CGI program to fetch the word docs, you can set the content-type dynamically and you can suggest a name for the file being downloaded.

My suggestion is that you just provide hyperlinks to the Word documents on your server. If people want to save it, they can either click the link then use the Word menus or, if they're using Windows and IE, they can right click on the link and save the target. Almost all browsers on all platforms have some provision for saving the target of alink.

Trust the users. They know how to use their software.

Good luck.

Jay

Collapse -

add it in your code

by monakardoost In reply to download Word document wi ...

Copy the following code into your HEAD tags:

<script language="JavaScript">
<!--
/*
No rightclick script v.2.5
(c) 1998 barts1000
barts1000@aol.com
Don't delete this header!
*/

var message="Sorry, that function is disabled.\nThis Page Copyrighted and\nImages and Text protected!\nALL RIGHTS RESERVED";

// Don't edit below!

function click(e) {
if (document.all) {
if (event.button == 2) {
alert(message);
return false;
}
}
if (document.layers) {
if (e.which == 3) {
alert(message);
return false;
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
// -->

</script>

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums