Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open an external file from HTML

Tags:

html

I want a list of hyperlinks on a basic html page, which point to files on our corporate intranet.

When a user clicks the link, I want the file to open. They are excel spreadsheets, and this is an intranet environment, so I can count on everyone having Excel installed.

I've tried two things:

  1. The obvious and simple thing:
<a href="file://server/directory/file.xlsx">Click me!</a>
  1. A vbscript option that I found in a Google search:
<HTML>
<HEAD>
    <SCRIPT LANGUAGE=VBScript>
    Dim objExcel

    Sub Btn1_onclick()
    call OpenWorkbook("\\server\directory\file.xlsx")
    End Sub

    Sub OpenWorkbook(strLocation)

    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = true
    objExcel.Workbooks.Open strLocation
    objExcel.UserControl = true
    End Sub

    </SCRIPT>
    <TITLE>Launch Excel</Title>
</HEAD>
<BODY>
    <INPUT TYPE=BUTTON NAME=Btn1 VALUE="Open Excel File">
</BODY>
</HTML> 

I know this is a very basic question, but I would appreciate any help I can get.

Edit: Any suggestions that work in both IE and Firefox?

like image 416
JosephStyons Avatar asked Sep 19 '08 12:09

JosephStyons


People also ask

How do I load an external HTML file?

To load external HTML into a <div>, wrap your code inside the load() function. To load a page in div in jQuery, use the load() method.

How do I open a text file in HTML?

Open the saved HTML file in your favorite browser (double click on the file, or right-click - and choose "Open with").


1 Answers

Try formatting the link like this (looks hellish, but it works in Firefox 3 under Vista for me) :

<a href="file://///SERVER/directory/file.ext">file.ext</a>
like image 124
David Heggie Avatar answered Oct 19 '22 00:10

David Heggie