The moose likes HTML, CSS and JavaScript and the fly likes open file Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "open file" Watch "open file" New topic
Author

open file

Jackie Wang
Ranch Hand

Joined: Apr 18, 2002
Posts: 315
I am writing a webpage using MS frontpage.
I have a hyperlink to another Word file in the same directory.
When I get into this page and click on the hyperlink, browser goes to the word file directly.
Are there anyway to prompt the user an option
"save to disk" or "open the file"?
I don't know whether I have posted this msg @ the right page. But thanks!
John Hembree
hired gun
Ranch Hand

Joined: Mar 07, 2003
Posts: 250
I hope that this will work for you. I found it here. This is client side vb script. You can wrap it in a function and then add it to your <a href> tag as an onClick event.

[ May 03, 2003: Message edited by: John Hembree ]
John Hembree
hired gun
Ranch Hand

Joined: Mar 07, 2003
Posts: 250
This one works, this would be a lot simpler. It's from here.
Multipurpose Internet Mail Extensions (MIME) is a wonderful thing,
allowing your Web browser to automatically display content of many
different formats natively within the browser window. However,
sometimes, you may want users to download this content to their
client computer rather than simply viewing it in the browser. But
how do you override the browser's determination to render known
MIME types itself? The answer is to use a content disposition
header in your Web page.
Suppose you've written an ASP page that contains a link to a known
MIME type, but you want the user to download the file instead of
viewing it. Here's an example:

Then substitute the actual filename and extension, and it's as good as done. When your users click on the link, they'll immediately see the download dialog box instead of the file's contents.
[ May 04, 2003: Message edited by: John Hembree ]
Jackie Wang
Ranch Hand

Joined: Apr 18, 2002
Posts: 315
thanks,
however, if I wanna include this script in a simple html page, is that possible?
Thanks!
 
 
subject: open file
 
Threads others viewed
opening a file
Open a JSP page without doing hardcoded the credential in hyperlink.
download help
hyperlink to file on C: drive does not work
opening an excel file through Java
developer file tools