Link to home
Start Free TrialLog in
Avatar of diek_nf
diek_nfFlag for Canada

asked on

prevent word document opening internet explorer

Hi,
Is it possible to prevent, via code, a word doc from opening in Internet Explorer. If so how? Thank you and have a great day programming,
diek
Avatar of thunderchicken
thunderchicken

<%
Response.ContentType = "application/msword"
Response.Redirect("yourdoc.doc")
%>
Avatar of diek_nf

ASKER

T,
I should have added that it has been a while since I played areound with ASP or HTM, or maybe it was obvious from my question. So, placing the code.

<%
Response.ContentType = "application/msword"
Response.Redirect("/downloads/DonaldDuck.doc")
%>

<p align="center"><a href="/downloads/DonaldDuck.doc" >Download User Manual</a></p>
d
ASKER CERTIFIED SOLUTION
Avatar of thunderchicken
thunderchicken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of diek_nf

ASKER

T,
I apologize, I just talked to my boss and our web server is not asp compatible. Can I covert the above to htm via script.
d
Are you saying that you want the word document to open inside Word rather than Internet Explorer. If so the short answer is no because this is controlled by IEs settings. Obvisouly if it is just your machine then you can change your settings.

You do this by going into Windows Explorer | Tools | Folder Options | File Types. Find the .doc extension then edit it or select advanced (depending on os) and deslect 'browse in same window'.

But bear in mind this effects all word documents that you may access via IE.

HTH
Steve
Avatar of diek_nf

ASKER

Steve,
Thanks for helping.

We want the word doc to download/save to disk. We do not want it opening in IE or Word. Independent of how the user has his or her browser set up.

Thunderchicken,
I hope you are not annoyed, I need your help,

diek
Ok then this is possible but potentially a bit tricky.

Firstly you will need to specify the wrong content type for the word file. Now I have a feeling (although am willing to be corrected) that if you pass IE a content type that it doesn't understand but it recognises the extension then it will open it in Word (in this case) anyway.

So I suspect the best content type to use is application/octet-stream

From plain HTML you can't get this mime type output although if you have access to the server configuration you might be ble to do it.

You could zip up the word document as a self extracting zip file which would probably do the trick.

Can you use anything other than just HTML/Javascript on the server (a perl CGI for example)?

Steve

diek,

I believe there's a way to do it using just HTML.  Javascript wont help since it's ran on the client.  Mouatts is in the right ballpark, I just don't know off the top of my head how to do it directly in HTML.
Thats the point thunderchicken you can't do it in HTML because it isn't HTML that you are downloading its a word document.

There is no mechanism on a link or within a form that indictates what the mime-type of the requested resource should be, if there were it would run contrary to the entire philosophy of HTTP. It can only be done as part of the response which by definition occurs at the server.

Steve
Avatar of diek_nf

ASKER

T,
I did not specify htm in my question, so you answered the question. We are trying to get our coy to use a no-unix server so we can use asp pages. Am i incorrect in assuming that unix servers cannot use asp?
d
No you are not correct if the server runs something called chillisoft then it can run asp although not many of the com objects that you can add on.

By the way I think it was a big mistake to accept the answer because it is wrong.

A redirection may not have any other header preceding it so the content type message is either junked or the redirection will fail.

When the redirection actually executes it is like a fresh request and new content types etc will be output.

More importantly it did not solve your problem.

You had already said that asp was a non-starter so to then go back an accept this as an answer just wastes the time of anyone else who has responded.

Steve
You can actually, chilisoft.com has ASP for apache I believe.  You can check it out and people have used it with moderate success.
Avatar of diek_nf

ASKER

steve,
I don't like pissing people off, if I had specified in my question HTM only it would be wrong. We are in the ASP area, so presumebly if someone saw this posting in ASP. Do you have the patience to get it working in asp?
==============================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
     <title>Untitled</title>
</head>

<body>
<p align="center"><a href="download.asp?doc=HazcomManual.doc" >Download User Manual</a></p>


</body>
</html>

===============Download.asp====================
<%
Response.ContentType = "application/msword"
Response.Redirect(request.querystring("doc"))
%>