Click to See Complete Forum and Search --> : how to save doc file in html page


vinitjain
July 22nd, 2002, 10:08 AM
hi,
i am faced with a strange n peculiar stupid problem. I am giving a *.doc file in a href tag of html page and instead of opening the file save dialog box, its opening the file in Browser.

CAn i somehow getover this problem, and prompt the user to save the doc file instead of opening it in browser window itself.

somebody help me pls...

rgds
vinit

sbrothy
July 23rd, 2002, 09:59 AM
Just passed by. I'm not quite sure what you mean by

I am giving a *.doc file in a href tag of html page

Do you mean to say that the user presses a link looking like:

http://foo.bar/baz.doc

or that the user is directed to your page like:

http://foo.bar/yourpage.html?document=baz.doc

?

Either way, I think your cances of getting a reply is better in the "Client Side Scripting" forum. This doesn't look like a topic for a "General Discussion" ;-)

Regards,
S. Bro

vinitjain
July 26th, 2002, 12:04 AM
i mean some thing like this < a href="abc.doc">XYZ </a>

can i somehow prompt the user to save this file... clicking on XYZ.. now it is opening the file in browser itself

sbrothy
July 26th, 2002, 03:10 AM
I think you can do something along the lines of (pseudocode):


<a href="abc.doc" onclick="doSave(this); return false;">XYZ </a>

<script language="javascript>
function doSave(anchor) {
var w = new ActiveXObject("Word.Application");
w.Documents.Add(anchor.href.value);
var doc = w.Application.ActiveDocument;
doc.SaveAs(documentPath, 0);
doc.Close(0);
}
</script>


You'd have to roam USENET and check the MSDN office documentation for the Word automation API.