Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

prevent word document opening internet explorer

Posted on 2002-06-11
13
296 Views
Last Modified: 2010-07-27
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
0
Comment
Question by:diek_nf
  • 5
  • 4
  • 4
13 Comments
 
LVL 11

Expert Comment

by:thunderchicken
ID: 7069790
<%
Response.ContentType = "application/msword"
Response.Redirect("yourdoc.doc")
%>
0
 

Author Comment

by:diek_nf
ID: 7069855
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
0
 
LVL 11

Accepted Solution

by:
thunderchicken earned 65 total points
ID: 7069881
Try this then

yourpage.asp

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


download.asp

<%
Response.ContentType = "application/msword"
Response.Redirect(request.querystring("doc"))
%>
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:diek_nf
ID: 7069903
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
0
 
LVL 11

Expert Comment

by:mouatts
ID: 7070082
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
0
 

Author Comment

by:diek_nf
ID: 7070339
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
0
 
LVL 11

Expert Comment

by:mouatts
ID: 7070512
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

0
 
LVL 11

Expert Comment

by:thunderchicken
ID: 7070704
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.
0
 
LVL 11

Expert Comment

by:mouatts
ID: 7070802
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
0
 

Author Comment

by:diek_nf
ID: 7070852
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
0
 
LVL 11

Expert Comment

by:mouatts
ID: 7070909
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
0
 
LVL 11

Expert Comment

by:thunderchicken
ID: 7070911
You can actually, chilisoft.com has ASP for apache I believe.  You can check it out and people have used it with moderate success.
0
 

Author Comment

by:diek_nf
ID: 7070986
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"))
%>
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question