View Full Version : HTML Hyperlink nightmare


coopster1974
31-07-2007, 18:29
Hi

Any bods out there know how to hyperlink to a .txt or .doc file and have the new window open as a word doc or wordpad? I keep having them open in a new browser window which I dont want!

I'm probaly missing something really easy but I dont get to play around with this stuff too often.

cheers in advance.

maggi
31-07-2007, 19:19
Is this you wanting to control your own computer's behaviour when clicking on the links, or are you trying to write a webpage where the viewer's computer does what you want?

Ghozer
31-07-2007, 19:22
if you have word installed, it should automatically open in a new browser window or tab with the word headers, just as an excel sheet does..

as for .txt they are read as plain text, and will just show as plain text in a a new window or tab

mrmist
31-07-2007, 19:23
AFAIK this behaviour is controlled by the user agent, so you can't fix it server side.

esme
31-07-2007, 19:31
If you are using something like perl to generate the page you can tell the browser you are sending a text file by manipulating the headers with code like

print( "HTTP/1.0 200 OKContent-type:text/plain;\n" );
print( "Content-disposition: attachment; filename=file.txt;\n" );
print( "\n" );

sent before any other output, then anything the server side app generates will be dumped into a text file at the client end

however even this won't make the client open the file in an application all it will do is ask the user if they want to save the file, as mrmist says the client controls application behaviour not the server